Gemini API
Chuizi.AI proxies the Gemini API as a native passthrough. Requests follow Google's generateContent / streamGenerateContent format and go directly to Google with automatic failover for high availability. No format conversion happens in either direction.
Use this protocol when you work with the Google AI SDK or any tool that expects the Gemini API format.
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /gemini/v1beta/models/{model}:generateContent | Generate content (non-streaming) |
POST | /gemini/v1beta/models/{model}:streamGenerateContent | Generate content (streaming SSE) |
GET | /gemini/v1beta/models | List available Gemini models |
The {model} parameter is the bare model name (e.g., gemini-2.5-flash, gemini-2.5-pro). The provider/model prefix format (google/gemini-2.5-flash) also works.
Authentication
Chuizi.AI accepts your ck- API key through these headers:
| Header | Format | Notes |
|---|---|---|
x-goog-api-key | ck-your-key-here | Google AI SDK default |
Authorization | Bearer ck-your-key-here | General convention |
Both resolve to the same user account, balance, and rate limits.
Request Format
The Gemini API uses a contents array where each entry has a role (user or model) and parts (an array of content pieces).
{ "contents": [ { "role": "user", "parts": [ {"text": "Explain how garbage collection works in Go."} ] } ], "generationConfig": { "temperature": 0.7, "maxOutputTokens": 1024, "topP": 0.9, "topK": 40 } }
Supported Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
contents | array | Yes | Conversation turns. Each entry has role and parts. |
generationConfig | object | No | Controls generation behavior. |
systemInstruction | object | No | System-level instruction. Same format as a content entry. |
tools | array | No | Tool/function definitions. |
toolConfig | object | No | Tool calling configuration. |
safetySettings | array | No | Content safety thresholds. |
generationConfig Options
| Field | Type | Description |
|---|---|---|
temperature | number | Sampling temperature, 0-2. |
topP | number | Nucleus sampling threshold. |
topK | integer | Top-K sampling. |
maxOutputTokens | integer | Maximum tokens to generate. |
stopSequences | array | Up to 5 custom stop sequences. |
responseMimeType | string | text/plain or application/json for JSON mode. |
responseSchema | object | JSON schema for structured output (when responseMimeType is application/json). |
Next Steps
- Choosing a Protocol — Compare all supported protocols side by side
- Anthropic Messages API — Native passthrough for Claude models
- Streaming Guide — Handle SSE streaming responses from Gemini