Text Generation (Gemini)
/api/v1/v1beta/models/{model_name}:{action}Path Parameters
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
Operation type, supporting non-streaming generateContent and streaming streamGenerateContent.
Header Parameters
Use Bearer Token authentication. Format: Authorization: Bearer sk-xxxxxx
Request Body
application/json
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").
Value in"user" | "model"
"model" | "user" | "assistant" | "tool"Ordered parts that make up a single message. Parts may have different MIME types.
Inline text.
Embedded media bytes.
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.
Raw bytes in media format. Use a base64-encoded string.
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.
Response Body
application/json
Success
TypeScript Definitions
Use the response body type in TypeScript.
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
}
}