Skip to content

Gemini Text Chat (Native Format)

In addition to the OpenAI-compatible format, YouQi AI exposes the Google Gemini native API, compatible with the official Gemini request / response structure, so you can use Google's SDK or an existing Gemini integration directly. This page covers text-only chat; for image / PDF / audio / video recognition see Gemini Media Recognition.

Endpoint & authentication

ItemValue
Base URLhttps://ai.youqi.tech/v1beta
Generate contentPOST /v1beta/models/{model}:generateContent
StreamingPOST /v1beta/models/{model}:streamGenerateContent
List modelsGET /v1beta/models
Authquery param ?key=<YOUR_API_KEY> or header x-goog-api-key: <YOUR_API_KEY>

Different Base URL

The Gemini native surface uses the Base URL https://ai.youqi.tech/v1beta (not /v1), and authenticates via the ?key= query parameter or the x-goog-api-key header. The API key is still the sk-... key you create in the console.

Generate content

Request parameters

ParameterTypeRequiredDescription
contentsarrayYesConversation contents, each with role (user / model) and parts
parts[].textstringYesText content (or inline_data for images and other multimodal input)
systemInstructionobjectNoSystem instruction
generationConfigobjectNoGeneration config such as temperature, topP, maxOutputTokens
toolsarrayNoTool / function declarations

Request example

bash
curl "https://ai.youqi.tech/v1beta/models/gemini-1.5-pro:generateContent?key=sk-YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      { "role": "user", "parts": [{ "text": "Introduce Hangzhou in one sentence." }] }
    ]
  }'

Passing the key via header (equivalent):

bash
curl "https://ai.youqi.tech/v1beta/models/gemini-1.5-pro:generateContent" \
  -H "x-goog-api-key: sk-YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "contents": [{ "role": "user", "parts": [{ "text": "Hello" }] }] }'

Response example

json
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          { "text": "Hangzhou is a city famed for West Lake, blending deep history with a vibrant digital economy." }
        ]
      },
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 8,
    "candidatesTokenCount": 22,
    "totalTokenCount": 30
  }
}

Streaming

Change the endpoint method to :streamGenerateContent; the server returns JSON in chunks:

bash
curl "https://ai.youqi.tech/v1beta/models/gemini-1.5-pro:streamGenerateContent?key=sk-YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "contents": [{ "role": "user", "parts": [{ "text": "Write a short poem about autumn" }] }] }'

Note

If you use the OpenAI SDK, you can also call Gemini models via the Chat endpoint (/v1/chat/completions) — the gateway handles protocol conversion automatically. The native /v1beta API suits existing Google SDK integrations or Gemini-specific structures. For image / PDF / audio / video recognition, see Gemini Media Recognition.