POST
/
v1beta
/
models
/
{model}
Gemini
curl --request POST \
  --url https://coder.api.visioncoder.cn/v1beta/models/{model} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "stream": true,
  "model": "<string>",
  "contents": [
    {
      "parts": [
        {}
      ],
      "role": "<string>"
    }
  ],
  "tools": [
    {
      "function_declarations": [
        {}
      ]
    }
  ],
  "candidate_count": 123,
  "temperature": 123,
  "top_p": 123,
  "top_k": 123,
  "max_output_tokens": 123,
  "stop_sequences": [
    "<string>"
  ],
  "safety_settings": [
    {
      "category": "<string>",
      "threshold": "<string>"
    }
  ],
  "response_modalities": [
    "<string>"
  ]
}
'
{
  "candidates": [
    {
      "index": 123,
      "content": {
        "parts": [
          {}
        ],
        "role": "<string>"
      },
      "finish_reason": "<string>",
      "safety_ratings": [
        {
          "category": "<string>",
          "probability": "<string>"
        }
      ],
      "citation_metadata": {
        "citation_sources": [
          {
            "uri": "<string>",
            "start": 123,
            "end": 123,
            "license": "<string>",
            "publication_date": "<string>"
          }
        ]
      },
      "token_count": 123
    }
  ],
  "model_version": "<string>",
  "created": 123,
  "usage_metadata": {
    "prompt_token_count": 123,
    "candidates_token_count": 123,
    "total_token_count": 123,
    "cached_content_token_count": 123,
    "tool_use_prompt_token_count": 123
  }
}

调用示例

curl "https://coder.api.visioncoder.cn/v1beta/models/gemini-2.5-pro:generateContent" \
  -H "x-goog-api-key: $VISIONCODER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {"role": "user", "parts": [{"text": "Hello"}]}
    ]
  }'

响应示例

{
  "candidates": [
    {
      "index": 0,
      "content": {
        "role": "model",
        "parts": [
          { "text": "Hi! How can I help you today?" }
        ]
      },
      "finish_reason": "STOP",
      "safety_ratings": [
        { "category": "HARM_CATEGORY_HARASSMENT",        "probability": "NEGLIGIBLE" },
        { "category": "HARM_CATEGORY_HATE_SPEECH",       "probability": "NEGLIGIBLE" },
        { "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "probability": "NEGLIGIBLE" },
        { "category": "HARM_CATEGORY_DANGEROUS_CONTENT", "probability": "NEGLIGIBLE" }
      ],
      "token_count": 10
    }
  ],
  "usage_metadata": {
    "prompt_token_count": 1,
    "candidates_token_count": 10,
    "total_token_count": 11
  }
}
流式变体使用 :streamGenerateContent,每个 chunk 是一个独立的 JSON 对象(换行分隔)。
路径走 /v1beta,模型名作为 URL 的一部分:models/{model}:generateContent

加群 & 客服

AI 技术交流群二维码
专属客服二维码

Authorizations

Authorization
string
header
required

Use the API key created at https://coder.visioncoder.cn/key as the Bearer token. Anthropic clients can pass the same key via the x-api-key header.

Path Parameters

model
string
required

Body

application/json
stream
boolean<boolean>
required
model
string

Model name (can also be in path)

contents
GeminiContent · object[]
system_instruction
GeminiContent · object
tools
GeminiTool · object[]
tool_config
GeminiToolConfig · object
candidate_count
integer<int32>
temperature
number<double>
top_p
number<double>
top_k
integer<int32>
max_output_tokens
integer<int32>
stop_sequences
string[]
safety_settings
GeminiSafetySetting · object[]
response_modalities
string[]

Response

200 - application/json

A successful response.

candidates
GeminiCandidate · object[]
required
model_version
string
required
created
integer<int64>
required
usage_metadata
GeminiUsageMetadata · object