典名词元DMTOKENSHome
API DocumentationThird-Party Tools Tutorial
AI Model APIText

Text Generation (Gemini)

POST/api/v1/v1beta/models/{model_name}:{action}

Path Parameters

model_name*string

Model name, optional gemini-2.5-pro gemini-2.5-flash gemini-2.5-flash-lite gemini-3-pro-preview gemini-3-flash-preview gemini-3.1-pro-preview gemini-3.1-flash-lite-preview

action*string

Operation type, supporting non-streaming generateContent and streaming streamGenerateContent.

Header Parameters

Authorization*string

Use Bearer Token authentication. Format: Authorization: Bearer sk-xxxxxx

Request Body

application/json

contents*array<object>

Array of conversation messages (excluding system messages). The role of each message must be either "user" or "assistant", and they must alternate (the first message must be "user").

[]?object
role*string

Value in"user" | "model"

Value in"model" | "user" | "assistant" | "tool"
parts?array<object>

Ordered parts that make up a single message. Parts may have different MIME types.

[]?object
text?string

Inline text.

inlineData?object

Embedded media bytes.

mimeType?string

The standard IANA MIME type for the source data. Examples: - image/png - image/jpeg If the provided MIME type is not supported, the system returns an error.

data?string

Raw bytes in media format. Use a base64-encoded string.

generationConfig?object
temperature?number
topP?number
topK?number
maxOutputTokens?integer
stopSequences?array<string>
[]?string
safetySettings?array<object>
[]?object
category?string
threshold?string
tools?array<object>

A piece of code that enables the system to interact with external systems to execute an action or a set of actions beyond the model's knowledge and scope.

[]?object
systemInstruction?object
parts?array<object>
[]?object

Response Body

application/json

Success

TypeScript Definitions

Use the response body type in TypeScript.

candidates*array<object>
[]?object
content?object
role*string
parts*array<object>
[]?object
finishReason?string
safetyRatings?array<object>
[]?object
usageMetadata*object
promptTokenCount*integer
candidatesTokenCount*integer
totalTokenCount*integer
curl -X POST "https://api.ygw.ai/api/v1/v1beta/models/string:string" \  -H "Authorization: string" \  -H "Content-Type: application/json" \  -d '{    "contents": [      {        "role": "model"      }    ]  }'
{
  "candidates": [
    {
      "content": {
        "role": "string",
        "parts": [
          {}
        ]
      },
      "finishReason": "string",
      "safetyRatings": [
        {}
      ]
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 0,
    "candidatesTokenCount": 0,
    "totalTokenCount": 0
  }
}