### Clone and Run the Wrapper Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Clones the repository, installs dependencies using Poetry, and starts the OpenAI-compatible Claude Code API server. Includes instructions for testing the setup. ```bash # 3. Clone and setup the wrapper git clone https://github.com/RichardAtCT/claude-code-openai-wrapper cd claude-code-openai-wrapper poetry install # 4. Start the server poetry run uvicorn main:app --reload --port 8000 # 5. Test it works poetry run python test_endpoints.py ``` ```bash # 1. Clone the repository: git clone https://github.com/RichardAtCT/claude-code-openai-wrapper cd claude-code-openai-wrapper # 2. Install dependencies with Poetry: poetry install # This will create a virtual environment and install all dependencies. # 3. Configure environment: cp .env.example .env # Edit .env with your preferences ``` -------------------------------- ### Cloud Platform Deployment Examples Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Commands for deploying the container to Heroku, Google Cloud Run, and AWS ECS, including necessary configurations. ```bash heroku container:push web gcloud run deploy --image yourusername/claude-wrapper --port 8000 --allow-unauthenticated ``` -------------------------------- ### Install Poetry Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Provides instructions for installing Poetry, a dependency management tool for Python, which is required for setting up the wrapper. ```bash # Install Poetry (if not already installed) curl -sSL https://install.python-poetry.org | python3 - ``` -------------------------------- ### Installing Development Dependencies Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Command to install development-specific dependencies using Poetry, including the 'dev' extra. ```bash # Install development dependencies poetry install --with dev ``` -------------------------------- ### Install and Authenticate Claude Code CLI Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Installs the Claude Code CLI using npm and authenticates the user, which is a prerequisite for using the wrapper. It also shows how to set the ANTHROPIC_API_KEY environment variable as an alternative authentication method. ```bash # 1. Install Claude Code CLI (if not already installed) npm install -g @anthropic-ai/claude-code # 2. Authenticate (choose one method) claude auth login # Recommended for development # OR set: export ANTHROPIC_API_KEY=your-api-key ``` ```bash # Install Claude Code (follow Anthropic's official guide) npm install -g @anthropic-ai/claude-code ``` ```bash # Option A: Authenticate via CLI (Recommended for development) claude auth login # Option B: Set environment variable export ANTHROPIC_API_KEY=your-api-key ``` -------------------------------- ### Running the Server Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Provides instructions on how to run the Claude Code OpenAI wrapper server. It includes commands for checking the Claude version, testing a model, and starting the server in development mode (with auto-reloading) or production mode, including port configuration options. ```bash claude --version claude --print --model claude-3-5-haiku-20241022 "Hello" # Test with fastest model ``` ```bash # Development mode (recommended - auto-reloads on changes): poetry run uvicorn main:app --reload --port 8000 ``` ```bash # Production mode: poetry run python main.py ``` ```bash # Specify custom port: poetry run python main.py 9000 # Set in environment: PORT=9000 poetry run python main.py ``` -------------------------------- ### API Security Configuration and Usage Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Explains how to configure API key protection for the server. It covers interactive prompts for enabling protection, using an environment variable for the API key, and provides an example of how to use the generated API key with curl. ```bash poetry run python main.py ``` ```bash # Example: Interactive protection enabled poetry run python main.py # Output: # ============================================================ # 🔐 API Endpoint Security Configuration # ============================================================ # Would you like to protect your API endpoint with an API key? # This adds a security layer when accessing your server remotely. # # Enable API key protection? (y/N): y # # 🔑 API Key Generated! # ============================================================ # API Key: Xf8k2mN9-vLp3qR5_zA7bW1cE4dY6sT0uI # ============================================================ # 📋 IMPORTANT: Save this key - you'll need it for API calls! # Example usage: # curl -H "Authorization: Bearer Xf8k2mN9-vLp3qR5_zA7bW1cE4dY6sT0uI" \ # http://localhost:8000/v1/models # ============================================================ ``` -------------------------------- ### Session Continuity with curl Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Provides examples of using session continuity with `curl` commands. This demonstrates how to initiate and continue conversations with a specified `session_id`. ```bash # First message (add -H "Authorization: Bearer your-key" if auth enabled) curl -X POST http://localhost:8000/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "claude-3-5-sonnet-20241022", "messages": [{"role": "user", "content": "My favourite color is blue."}], "session_id": "my-session" }' # Follow-up message - context is maintained curl -X POST http://localhost:8000/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "claude-3-5-sonnet-20241022", "messages": [{"role": "user", "content": "What's my favourite color?"}], "session_id": "my-session" }' ``` -------------------------------- ### Dockerfile for Claude Code OpenAI Wrapper Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Defines the Docker image configuration. It uses a Python 3.12 base image and installs necessary dependencies including Poetry, Node.js, FastAPI, Uvicorn, and the Claude Code SDK. This Dockerfile is intended to be placed in the root of the project repository. ```dockerfile # Example Dockerfile content (actual content not provided in source text) # FROM python:3.12-slim # WORKDIR /app # COPY . . # RUN pip install --no-cache-dir poetry # RUN poetry install # CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] ``` -------------------------------- ### Troubleshooting Claude CLI Not Found Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Provides commands to check if the Claude CLI is installed and accessible in the system's PATH, and how to update the CLAUDE_CLI_PATH environment variable if necessary. ```bash # Check Claude is in PATH which claude # Update CLAUDE_CLI_PATH in .env if needed ``` -------------------------------- ### Session Management API Endpoints Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Defines the API endpoints for managing sessions, including listing, retrieving, deleting, and getting statistics for active sessions. ```APIDOC GET /v1/sessions - List all active sessions GET /v1/sessions/{session_id} - Get detailed session information DELETE /v1/sessions/{session_id} - Delete a specific session GET /v1/sessions/stats - Get session manager statistics ``` -------------------------------- ### Running Basic Test Suite Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Instructions to run the comprehensive basic test suite, including how to set an API key for protection. ```bash # Make sure server is running first poetry run python test_basic.py # With API key protection enabled, set TEST_API_KEY: TEST_API_KEY=your-generated-key poetry run python test_basic.py ``` -------------------------------- ### Running Quick Test Suite Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Instructions to run a quick test suite against all endpoints, assuming the server is already running. ```bash # Make sure server is running first poetry run python test_endpoints.py ``` -------------------------------- ### Build Docker Image Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Builds the Docker image for the Claude Code OpenAI Wrapper. The `-t` flag tags the image, and `.` specifies the build context. The build process downloads dependencies and sets up the environment. It can take 5-15 minutes on the first run and results in an image size of approximately 200-300MB. ```bash docker build -t claude-wrapper:latest . ``` -------------------------------- ### Wrapper Configuration Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Shows the configuration options available in the `.env` file for the Claude Code OpenAI API Wrapper. This includes settings for the Claude CLI path, API key, server port, timeouts, CORS origins, and working directory. ```env # Claude CLI path (usually just "claude") CLAUDE_CLI_PATH=claude # Optional API key for client authentication # If not set, server will prompt for interactive API key protection on startup # API_KEY=your-optional-api-key # Server port PORT=8000 # Timeout in milliseconds MAX_TIMEOUT=600000 # CORS origins CORS_ORIGINS=["*"] # Working directory for Claude Code (optional) # If not set, uses an isolated temporary directory for security # CLAUDE_CWD=/path/to/your/workspace ``` -------------------------------- ### OpenAI Python SDK Integration Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Shows how to configure and use the OpenAI Python SDK to interact with the local Claude wrapper API. ```python from openai import OpenAI client = OpenAI( base_url="http://localhost:8000/v1", api_key="your-api-key-if-required" # Only needed if protection enabled ) ``` -------------------------------- ### Environment Variables for Configuration Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Lists and explains environment variables used to configure the Claude Code OpenAI Wrapper, covering server settings, authentication, provider selection, and security. ```APIDOC ## Environment Variables Customise the container's behaviour through environment variables. These can be set at runtime with `-e` flags or in `docker-compose.yml` under `environment`. ### Core Server Settings: - `PORT`: Changes the internal listening port (default: 8000). - `MAX_TIMEOUT`: Sets the request timeout in seconds (default: 300). - `CLAUDE_CWD`: Sets Claude Code's working directory (default: isolated temp directory). ### Authentication and Providers: - `ANTHROPIC_API_KEY`: Enables direct API key authentication. - `CLAUDE_CODE_USE_VERTEX`: Switches to Google Vertex AI. - `CLAUDE_CODE_USE_BEDROCK`: Enables AWS Bedrock. - `CLAUDE_USE_SUBSCRIPTION`: Forces subscription mode. ### Security and API Protection: - `API_KEYS`: Comma-separated list of API keys for endpoint access. ### Custom/Advanced Vars: - `MAX_THINKING_TOKENS`: Custom token budget for extended thinking. - `ANTHROPIC_CUSTOM_HEADERS`: JSON string for custom SDK headers. **Example Usage:** ```bash docker run ... -e PORT=9000 -e ANTHROPIC_API_KEY=sk-your-key ... ``` **Persistence:** Use a `.env` file in the root (e.g., `PORT=8000`) and mount it: `-v $(pwd)/.env:/app/.env`. ``` -------------------------------- ### Docker Image Deployment Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Steps to tag and push the Docker image to a registry for deployment on remote servers or cloud platforms. ```bash docker tag claude-wrapper:latest yourusername/claude-wrapper:latest docker push yourusername/claude-wrapper:latest ``` -------------------------------- ### Remote Server Deployment Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Instructions for deploying the Docker image on a remote server, including pulling the image, running it with persistent storage, and daemonizing the process. ```bash docker pull yourusername/claude-wrapper:latest docker run -v /server/path/to/claude:/root/.claude ... yourusername/claude-wrapper:latest ``` -------------------------------- ### Docker Compose Configuration Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Defines the service for the Claude Code OpenAI Wrapper using Docker Compose. Includes build context, port mapping, volume mounts, environment variables, and a development command. ```yaml version: '3.8' services: claude-wrapper: build: . ports: - "8000:8000" volumes: - ~/.claude:/root/.claude - .:/app # Optional for dev environment: - PORT=8000 - MAX_TIMEOUT=600 command: ["poetry", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"] # Dev example restart: unless-stopped ``` -------------------------------- ### Troubleshooting Authentication Errors Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Offers a command to test authentication with the fastest Claude model and advises on re-authentication if the test fails. ```bash # Test authentication with fastest model claude --print --model claude-3-5-haiku-20241022 "Hello" # If this fails, re-authenticate if needed ``` -------------------------------- ### Running Pytest Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Command to execute the full test suite using Pytest, intended for when tests are implemented. ```bash # Run full tests (when implemented) poetry run pytest tests/ ``` -------------------------------- ### Development Run with Docker Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Runs the Claude Code OpenAI Wrapper in development mode with hot-reloading enabled. Mounts the current directory for live code edits and maps port 8000. ```bash docker run -d -p 8000:8000 \ -v ~/.claude:/root/.claude \ -v $(pwd):/app \ --name claude-wrapper-container \ claude-wrapper:latest \ poetry run uvicorn main:app --host 0.0.0.0 --port 8000 --reload ``` -------------------------------- ### API Models List Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Retrieves a list of available models supported by the API. ```bash curl http://localhost:8000/v1/models ``` -------------------------------- ### Verify Docker Image Build Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Verifies that the Docker image has been successfully built by listing all Docker images and filtering for those tagged with 'claude-wrapper'. This command helps confirm the image's presence and details like its tag and size. ```bash docker images | grep claude-wrapper ``` -------------------------------- ### API Documentation: Models List Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Retrieves a list of all available models that the API can use. ```APIDOC GET /v1/models Description: Returns a list of all the models available through the API. Authentication: - API Key: `Authorization: Bearer YOUR_API_KEY` (if enabled). - No Auth: If API key protection is disabled, no authorization header is required. Response: - `data` (array of objects): A list of model objects. - Each model object contains `id` (string), `object` (string, e.g., 'model'), `created` (integer timestamp), `owned_by` (string), and `permission` (array). Example Request: ```bash curl http://localhost:8000/v1/models ``` ``` -------------------------------- ### Docker Runtime Flags Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Configures container resource limits, networking, restart policies, and user permissions for safe and efficient execution. ```bash --cpus=2 --memory=2g --network host --restart unless-stopped --user $(id -u):$(id -g) ``` -------------------------------- ### Volumes for Data Persistence and Customisation Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Explains the use of Docker volumes for persisting data and customising the container's environment, including authentication, code mounting, configuration files, and credential management. ```APIDOC ## Volumes for Data Persistence and Customisation Volumes mount host directories/files into the container, enabling persistence and config overrides. - **Authentication Volume (Required for Subscriptions)**: `-v ~/.claude:/root/.claude` – Shares tokens and `settings.json`. - **Code Volume (Dev Only)**: `-v $(pwd):/app` – Allows live edits without rebuilds. - **Custom Config Volumes**: - Mount a custom config: `-v /path/to/custom.json:/app/config/custom.json`. - Logs: `-v /path/to/logs:/app/logs` for external log access. - **Credential Files**: For Vertex/Bedrock, `-v /path/to/creds.json:/app/creds.json` and set env var to point to it. **Note:** Volumes survive container restarts but are deleted on `docker rm -v`. Consider named volumes for better management. ``` -------------------------------- ### Configure Working Directory Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Demonstrates how to configure the working directory for Claude Code. It can run in an isolated temporary directory (default and recommended) or a custom directory specified via an environment variable or a .env file. ```bash poetry run python main.py ``` ```bash export CLAUDE_CWD=/path/to/your/project poetry run python main.py ``` ```env CLAUDE_CWD=/home/user/my-workspace ``` -------------------------------- ### Docker Post-Run Management Commands Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Common Docker commands for managing the running container, including viewing logs, checking status, stopping, restarting, and removing the container. ```bash # View Logs docker logs claude-wrapper-container # Check Status docker ps docker stats # Stop/Restart docker stop claude-wrapper-container docker start claude-wrapper-container # Remove (after stopping) docker rm claude-wrapper-container # Cleanup unused resources docker system prune ``` -------------------------------- ### API Chat Completion with Stream and Auth Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Demonstrates a chat completion request with streaming enabled and API key authentication. ```bash curl -X POST http://localhost:8000/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your-generated-api-key" \ -d '{ "model": "claude-3-5-sonnet-20241022", "messages": [ {"role": "user", "content": "Write a Python hello world script"} ], "stream": true }' ``` -------------------------------- ### Chat Completion with Tool Usage Enabled Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Shows how to enable tool usage for chat completions, allowing the model to access external tools like file system access. This is achieved by setting `enable_tools` to `True` in the `extra_body`. ```python response = client.chat.completions.create( model="claude-3-5-sonnet-20241022", messages=[ {"role": "user", "content": "What files are in the current directory?"} ], extra_body={"enable_tools": True} # Enable tools for file access ) print(response.choices[0].message.content) ``` -------------------------------- ### Session Management with curl Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Demonstrates how to manage active sessions using `curl` commands. This includes listing sessions, retrieving session details, and deleting sessions. ```bash # List active sessions curl http://localhost:8000/v1/sessions # Get session details curl http://localhost:8000/v1/sessions/my-session # Delete a session curl -X DELETE http://localhost:8000/v1/sessions/my-session ``` -------------------------------- ### Formatting Code with Black Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Command to format the project's code using the Black code formatter. ```bash # Format code poetry run black . ``` -------------------------------- ### Troubleshooting Docker Commands Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Common Docker commands for debugging and managing the container, including checking logs and entering the container shell. ```bash docker logs -f claude-wrapper-container docker exec -it claude-wrapper-container /bin/bash docker system prune -a ``` -------------------------------- ### API Documentation: Chat Completions Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Provides details on the chat completions endpoint, including request parameters, authentication, and response formats. ```APIDOC POST /v1/chat/completions Description: Enables chat-style interactions by processing a list of messages and returning a model-generated response. Authentication: - API Key: `Authorization: Bearer YOUR_API_KEY` (if enabled). - No Auth: If API key protection is disabled, no authorization header is required. Request Body: - `model` (string, required): The ID of the model to use for completion (e.g., `claude-3-5-sonnet-20240620`). - `messages` (array of objects, required): A list of message objects, each with `role` ('user', 'assistant', 'system') and `content` (string). - `stream` (boolean, optional): If true, sends partial message deltas as server-sent events. - Other parameters like `max_tokens`, `temperature`, `top_p`, etc., are supported as per OpenAI API. Response (Non-streaming): - `id` (string): Unique identifier for the completion. - `type` (string): Type of the response (e.g., 'chat.completion'). - `role` (string): The role of the model in the conversation (usually 'assistant'). - `content` (array of objects): The content of the model's response. Each object has `type` ('text') and `text` (string). - `stop_reason` (string): The reason the model stopped generating tokens (e.g., 'end_turn', 'max_tokens'). - `model` (string): The model used for the completion. - `usage` (object): Token usage statistics. Response (Streaming): - Server-Sent Events (SSE) stream, with each event containing a chunk of the response. Example Request: ```bash curl -X POST http://localhost:8000/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "claude-3-5-sonnet-20241022", "messages": [ {"role": "user", "content": "What is 2 + 2?"} ] }' ``` Example Streaming Request: ```bash curl -X POST http://localhost:8000/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your-generated-api-key" \ -d '{ "model": "claude-3-5-sonnet-20241022", "messages": [ {"role": "user", "content": "Write a Python hello world script"} ], "stream": true }' ``` ``` -------------------------------- ### Run Docker Container with Custom Workspace Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Runs the Docker container with a custom workspace mounted. It maps port 8000, mounts the host's `~/.claude` directory for authentication, and mounts a specified project directory (`/path/to/your/project`) to `/workspace` inside the container. The `CLAUDE_CWD` environment variable is set to `/workspace` to define the container's working directory. ```bash docker run -d -p 8000:8000 \ -v ~/.claude:/root/.claude \ -v /path/to/your/project:/workspace \ -e CLAUDE_CWD=/workspace \ --name claude-wrapper-container \ claude-wrapper:latest ``` -------------------------------- ### Tracking Costs and Tokens Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Illustrates how to track the cost and token usage of a completion request. The cost is calculated based on the total tokens and a predefined rate. ```python print(f"Cost: ${response.usage.total_tokens * 0.000003:.6f}") # Real cost tracking print(f"Tokens: {response.usage.total_tokens} ({response.usage.prompt_tokens} + {response.usage.completion_tokens})") ``` -------------------------------- ### Run Docker Container (Basic Production) Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Runs the Docker container in detached mode for background operation. It maps port 8000 from the host to the container and mounts the host's `~/.claude` directory to `/root/.claude` inside the container for authentication persistence. The container is named 'claude-wrapper-container'. ```bash docker run -d -p 8000:8000 \ -v ~/.claude:/root/.claude \ --name claude-wrapper-container \ claude-wrapper:latest ``` -------------------------------- ### Rate Limiting Configuration Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Details the rate limiting policies for different API endpoints and how to configure them using environment variables. It also shows the JSON response format for rate limit exceeded errors. ```json { "error": { "message": "Rate limit exceeded. Try again in 60 seconds.", "type": "rate_limit_exceeded", "code": "too_many_requests", "retry_after": 60 } } ``` ```bash RATE_LIMIT_ENABLED=true RATE_LIMIT_CHAT_PER_MINUTE=10 RATE_LIMIT_DEBUG_PER_MINUTE=2 RATE_LIMIT_AUTH_PER_MINUTE=10 RATE_LIMIT_HEALTH_PER_MINUTE=30 ``` -------------------------------- ### Basic Chat Completion Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Demonstrates a basic chat completion request without any special configurations. This is the default behavior, similar to the standard OpenAI API. ```python import openai client = openai.OpenAI( base_url="http://localhost:8000/v1", api_key="not-needed" ) response = client.chat.completions.create( model="claude-3-5-sonnet-20241022", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What files are in the current directory?"} ] ) print(response.choices[0].message.content) ``` -------------------------------- ### Streaming Chat Completion Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Demonstrates how to receive chat completion responses in a streaming fashion. This allows for real-time output as the model generates the response. ```python stream = client.chat.completions.create( model="claude-3-5-sonnet-20241022", messages=[ {"role": "user", "content": "Explain quantum computing"} ], stream=True ) for chunk in stream: if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="") ``` -------------------------------- ### Session Continuity with OpenAI SDK Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Shows how to maintain conversation context across multiple requests using session continuity. By providing a `session_id`, the model can remember previous interactions. ```python response1 = client.chat.completions.create( model="claude-3-5-sonnet-20241022", messages=[ {"role": "user", "content": "Hello! My name is Alice and I'm learning Python."} ], extra_body={"session_id": "my-learning-session"} ) response2 = client.chat.completions.create( model="claude-3-5-sonnet-20241022", messages=[ {"role": "user", "content": "What's my name and what am I learning?"} ], extra_body={"session_id": "my-learning-session"} # Same session ID ) # Claude will remember: "Your name is Alice and you're learning Python." ``` -------------------------------- ### API Endpoints Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Lists the core API endpoints available in the Claude Code OpenAI Wrapper. These endpoints cover chat completions, model listing, authentication status, and health checks. ```APIDOC POST /v1/chat/completions - OpenAI-compatible chat completions (supports `session_id`) GET /v1/models - List available models GET /v1/auth/status - Check authentication status and configuration GET /health - Health check endpoint GET /v1/sessions - List all active sessions GET /v1/sessions/{session_id} - Get session details DELETE /v1/sessions/{session_id} - Delete a session GET /v1/sessions/stats - Get session statistics ``` -------------------------------- ### API Chat Completion Request Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Sends a chat completion request to the API, specifying the model and user messages. ```bash curl http://localhost:8000/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{"model": "claude-3-5-sonnet-20240620", "messages": [{"role": "user", "content": "Hello"}]}' ``` -------------------------------- ### Checking Authentication Status Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md A curl command to check the current authentication status of the service, outputting the result in a formatted JSON. ```bash curl http://localhost:8000/v1/auth/status | python -m json.tool ``` -------------------------------- ### API Documentation: Health Check Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Checks the operational status of the API server. ```APIDOC GET /health Description: Provides a simple health check for the API server. Authentication: - No authentication required. Response: - `status` (string): Indicates the health status, typically "healthy". Example Request: ```bash curl http://localhost:8000/health ``` ``` -------------------------------- ### API Health Check Source: https://github.com/richardatct/claude-code-openai-wrapper/blob/main/README.md Verifies the container's operational status by sending a request to the health endpoint. ```bash curl http://localhost:8000/health ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.