Gemini 호환

사용 가능

구성된 경우 Gemini 호환 모델, 생성, 스트리밍 및 임베딩 경로를 사용합니다.

GET /v1beta/models

현재 API Key에서 볼 수 있는 Gemini 호환 모델을 나열합니다.

Gemini 모델 목록
curl https://www.token168.cc/v1beta/models \
  -H "Authorization: Bearer $TOKEN168_API_KEY"

POST /v1beta/models/{model}:generateContent

generateContent는 Gemini 네이티브 content, safety, tool, system instruction, cache 및 generationConfig 필드를 받습니다. 예제는 선택된 최신 모델 문서 예제인 gemini-3.1-pro를 사용합니다.

Gemini generateContent 생성
curl https://www.token168.cc/v1beta/models/gemini-3.1-pro:generateContent \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN168_API_KEY" \
  -d '{
    "contents": [{"role": "user", "parts": [{"text": "Summarize the release notes.", "thought": false}]}],
    "safetySettings": [{"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"}],
    "generationConfig": {
      "temperature": 0.4,
      "topP": 0.9,
      "topK": 40,
      "maxOutputTokens": 800,
      "candidateCount": 1,
      "stopSequences": ["END"],
      "responseMimeType": "application/json",
      "responseSchema": {"type": "object", "properties": {"summary": {"type": "string"}}},
      "responseJsonSchema": {"type": "object"},
      "presencePenalty": 0,
      "frequencyPenalty": 0,
      "responseLogprobs": false,
      "logprobs": 0,
      "enableEnhancedCivicAnswers": false,
      "mediaResolution": "MEDIA_RESOLUTION_MEDIUM",
      "seed": 123,
      "responseModalities": ["TEXT"],
      "thinkingConfig": {"includeThoughts": true, "thinkingBudget": 1024, "thinkingLevel": "medium"},
      "speechConfig": {"voiceConfig": {"prebuiltVoiceConfig": {"voiceName": "Kore"}}},
      "imageConfig": {"aspectRatio": "1:1"}
    },
    "tools": [{"functionDeclarations": [{"name": "lookup", "parameters": {"type": "object", "properties": {}}}]}],
    "toolConfig": {"functionCallingConfig": {"mode": "AUTO", "allowedFunctionNames": ["lookup"]}, "retrievalConfig": {"languageCode": "en"}, "includeServerSideToolInvocations": false},
    "systemInstruction": {"role": "system", "parts": [{"text": "Return concise JSON."}]},
    "cachedContent": "cachedContents/example"
  }'

POST /v1beta/models/{model}:streamGenerateContent

스트리밍은 스트리밍 action 또는 alt=sse 쿼리 매개변수와 함께 같은 요청 본문을 사용합니다.

Gemini 스트리밍
curl "https://www.token168.cc/v1beta/models/gemini-3.1-pro:streamGenerateContent?alt=sse" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN168_API_KEY" \
  -d '{
    "contents": [{"role": "user", "parts": [{"text": "Stream one paragraph."}]}],
    "generationConfig": {"temperature": 0.4, "topP": 0.9, "topK": 40, "maxOutputTokens": 400, "candidateCount": 1}
  }'

POST /v1beta/models/{model}:embedContent

구성된 경우 임베딩 형식의 Gemini 경로가 Gemini 릴레이 형식으로 라우팅됩니다.

Gemini 임베딩
curl https://www.token168.cc/v1beta/models/gemini-3.1-pro:embedContent \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN168_API_KEY" \
  -d '{
    "content": {"parts": [{"text": "Token168 docs"}]},
    "taskType": "RETRIEVAL_DOCUMENT",
    "title": "Docs"
  }'