### Docker Compose Hugging Face Setup Source: https://github.com/gzzhongqi/geminicli2api/blob/main/README.md Starts the geminicli2api service using Docker Compose with Hugging Face compatibility on port 7860. ```bash docker-compose --profile hf up -d geminicli2api-hf ``` -------------------------------- ### Docker Compose Default Setup Source: https://github.com/gzzhongqi/geminicli2api/blob/main/README.md Starts the geminicli2api service using Docker Compose on the default port 8888. ```bash docker-compose up -d ``` -------------------------------- ### Example Credentials JSON for Gemini API Source: https://github.com/gzzhongqi/geminicli2api/blob/main/README.md This JSON structure provides an example of the required credentials for authenticating with the Gemini API. Ensure you replace placeholder values with your actual credentials. ```json { "client_id": "your-client-id", "client_secret": "your-client-secret", "token": "your-access-token", "refresh_token": "your-refresh-token", "scopes": ["https://www.googleapis.com/auth/cloud-platform"], "token_uri": "https://oauth2.googleapis.com/token" } ``` -------------------------------- ### OpenAI API Example with Gemini Proxy Source: https://github.com/gzzhongqi/geminicli2api/blob/main/README.md Use the proxy as a drop-in replacement for the OpenAI API. Configure the client with your proxy URL and API key. ```python import openai # Configure client to use your proxy client = openai.OpenAI( base_url="http://localhost:8888/v1", # or 7860 for HF api_key="your_password" # Your GEMINI_AUTH_PASSWORD ) # Use like normal OpenAI API response = client.chat.completions.create( model="gemini-2.5-pro-maxthinking", messages=[ {"role": "user", "content": "Explain the theory of relativity in simple terms."} ], stream=True ) # Separate reasoning from the final answer for chunk in response: if chunk.choices[0].delta.reasoning_content: print(f"Thinking: {chunk.choices[0].delta.reasoning_content}") if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="") ``` -------------------------------- ### GET /v1beta/models Source: https://github.com/gzzhongqi/geminicli2api/blob/main/README.md Lists available Gemini models. ```APIDOC ## GET /v1beta/models ### Description Lists available Gemini models. ### Method GET ### Endpoint /v1beta/models ### Parameters #### Query Parameters - **key** (string) - Optional - API key for authentication. ### Response #### Success Response (200) (Details not provided in source) #### Response Example (Details not provided in source) ``` -------------------------------- ### Native Gemini API Example with Proxy Source: https://github.com/gzzhongqi/geminicli2api/blob/main/README.md Interact directly with the Gemini API through the proxy. Ensure correct headers and JSON payload are used. ```python import requests headers = { "Authorization": "Bearer your_password", "Content-Type": "application/json" } data = { "contents": [ { "role": "user", "parts": [{"text": "Explain the theory of relativity in simple terms."}] } ], "thinkingConfig": { "thinkingBudget": 32768, "includeThoughts": True } } response = requests.post( "http://localhost:8888/v1beta/models/gemini-2.5-pro:generateContent", # or 7860 for HF headers=headers, json=data ) print(response.json()) ``` -------------------------------- ### GET /v1/models Source: https://github.com/gzzhongqi/geminicli2api/blob/main/README.md Lists all available models that can be used with the API. This endpoint is compatible with the OpenAI API. ```APIDOC ## GET /v1/models ### Description Lists all available models that can be used with the API. This endpoint is compatible with the OpenAI API. ### Method GET ### Endpoint /v1/models ### Parameters #### Query Parameters - **key** (string) - Optional - API key for authentication. ### Response #### Success Response (200) (Details not provided in source) #### Response Example (Details not provided in source) ``` -------------------------------- ### GET /health Source: https://github.com/gzzhongqi/geminicli2api/blob/main/README.md Health check endpoint for container orchestration. ```APIDOC ## GET /health ### Description Health check endpoint for container orchestration. ### Method GET ### Endpoint /health ### Parameters (No parameters documented) ### Response #### Success Response (200) (Details not provided in source) #### Response Example (Details not provided in source) ``` -------------------------------- ### Build Docker Image Source: https://github.com/gzzhongqi/geminicli2api/blob/main/README.md Builds the Docker image for the geminicli2api application. ```bash docker build -t geminicli2api . ``` -------------------------------- ### Run Docker Container on Port 7860 Source: https://github.com/gzzhongqi/geminicli2api/blob/main/README.md Runs the geminicli2api Docker container on port 7860, compatible with Hugging Face. ```bash docker run -p 7860:7860 \ -e GEMINI_AUTH_PASSWORD=your_password \ -e GEMINI_CREDENTIALS='{"client_id":"...","token":"..."}' \ -e PORT=7860 \ geminicli2api ``` -------------------------------- ### POST /v1beta/models/{model}:generateContent Source: https://github.com/gzzhongqi/geminicli2api/blob/main/README.md Generates content using a specified Gemini model. This is a native Gemini API endpoint. ```APIDOC ## POST /v1beta/models/{model}:generateContent ### Description Generates content using a specified Gemini model. This is a native Gemini API endpoint. ### Method POST ### Endpoint /v1beta/models/{model}:generateContent ### Parameters #### Path Parameters - **model** (string) - Required - The name of the Gemini model to use. #### Query Parameters - **key** (string) - Optional - API key for authentication. #### Request Body (Details not provided in source) ### Request Example (Details not provided in source) ### Response #### Success Response (200) (Details not provided in source) #### Response Example (Details not provided in source) ``` -------------------------------- ### POST /v1/chat/completions Source: https://github.com/gzzhongqi/geminicli2api/blob/main/README.md Provides chat completions, supporting both streaming and non-streaming responses. This endpoint is compatible with the OpenAI API. ```APIDOC ## POST /v1/chat/completions ### Description Provides chat completions, supporting both streaming and non-streaming responses. This endpoint is compatible with the OpenAI API. ### Method POST ### Endpoint /v1/chat/completions ### Parameters #### Query Parameters - **key** (string) - Optional - API key for authentication. #### Request Body (Details not provided in source) ### Request Example (Details not provided in source) ### Response #### Success Response (200) (Details not provided in source) #### Response Example (Details not provided in source) ``` -------------------------------- ### Run Docker Container on Port 8888 Source: https://github.com/gzzhongqi/geminicli2api/blob/main/README.md Runs the geminicli2api Docker container on the default port 8888, compatible with OpenAI. ```bash docker run -p 8888:8888 \ -e GEMINI_AUTH_PASSWORD=your_password \ -e GEMINI_CREDENTIALS='{"client_id":"...","token":"..."}' \ -e PORT=8888 \ geminicli2api ``` -------------------------------- ### POST /v1beta/models/{model}:streamGenerateContent Source: https://github.com/gzzhongqi/geminicli2api/blob/main/README.md Streams content generated by a specified Gemini model. This is a native Gemini API endpoint. ```APIDOC ## POST /v1beta/models/{model}:streamGenerateContent ### Description Streams content generated by a specified Gemini model. This is a native Gemini API endpoint. ### Method POST ### Endpoint /v1beta/models/{model}:streamGenerateContent ### Parameters #### Path Parameters - **model** (string) - Required - The name of the Gemini model to use. #### Query Parameters - **key** (string) - Optional - API key for authentication. #### Request Body (Details not provided in source) ### Request Example (Details not provided in source) ### Response #### Success Response (200) (Details not provided in source) #### Response Example (Details not provided in source) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.