Generate Gemini content
Generate content with the native Google Gemini API schema. The model in the URL is a Token360 public model ID; use GET /v1/models to discover currently available models.
Endpoints
POST /v1beta/models/{model}:generateContent— return one JSON response.POST /v1beta/models/{model}:streamGenerateContent?alt=sse— stream Gemini JSON responses as Server-Sent Events.POST /v1beta/models/{model}:countTokens— not supported in this release and returns501 UNIMPLEMENTED.
The base URL for these endpoints is https://api.token360.ai. Do not append /v1 before /v1beta.
Authentication
Use either Google-compatible API key form:
- Header:
x-goog-api-key: sk-your-api-key - Query parameter:
?key=sk-your-api-key
The header form is recommended because URLs may be recorded by clients, proxies, and access logs.
Request body
The request follows the Gemini GenerateContentRequest wire format. Common fields include:
contentsContent[]Required. Conversation content. Each item contains a role and one or more parts.
systemInstructionContentOptional system instruction in Gemini Content format.
generationConfigobjectOptional generation controls such as maxOutputTokens, temperature, topP, topK, stopSequences, responseMimeType, and responseSchema. Support varies by model.
safetySettingsSafetySetting[]Optional Gemini safety settings.
toolsTool[]Optional tools, including functionDeclarations.
tools.typestringTool type, usually function.
tools.functionobjectFunction definition.
toolConfigToolConfigOptional function-calling configuration.
Token360 preserves Gemini field names and does not require a top-level model field because the model is part of the URL.
Non-streaming example
1curl https://api.token360.ai/v1beta/models/gemini-2.5-flash:generateContent \
2 -H 'x-goog-api-key: sk-your-api-key' \
3 -H 'Content-Type: application/json' \
4 -d '{
5 "contents": [{
6 "role": "user",
7 "parts": [{"text": "Explain vector databases in one sentence."}]
8 }]
9 }'A successful response uses the native Gemini shape, including fields such as candidates, usageMetadata, and modelVersion when supplied by the upstream model.
Streaming example
Set alt=sse on streamGenerateContent:
1curl -N 'https://api.token360.ai/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sse' \
2 -H 'x-goog-api-key: sk-your-api-key' \
3 -H 'Content-Type: application/json' \
4 -d '{
5 "contents": [{
6 "role": "user",
7 "parts": [{"text": "Write a two-line greeting."}]
8 }]
9 }'Each SSE data: event contains a Gemini response object. Consume Gemini candidate parts in order and finish when the stream closes; do not expect the OpenAI [DONE] sentinel.
Multi-turn conversations
Gemini native requests are stateless. To continue a conversation, resend the earlier user and model contents with the new user turn:
1{
2 "contents": [
3 {"role": "user", "parts": [{"text": "My project is called Aurora."}]},
4 {"role": "model", "parts": [{"text": "Understood."}]},
5 {"role": "user", "parts": [{"text": "What is my project called?"}]}
6 ]
7}Function calling
Declare functions under tools[].functionDeclarations. A model function call is returned as a functionCall part. Send the tool result in a later functionResponse part together with the preceding conversation contents. Both non-streaming and streaming endpoints preserve these Gemini-native parts.
Errors
Gemini endpoints return Google-style errors. Use the HTTP status as the primary failure signal:
1{
2 "error": {
3 "code": 400,
4 "message": "Invalid request",
5 "status": "INVALID_ARGUMENT"
6 }
7}Routing, usage, and billing
Although the wire format is Gemini-native, Token360 still performs API-key authentication, SKU and provider routing, provider credential injection, error normalization, request archiving, usage statistics, and billing. Usage from generateContent and streamGenerateContent appears in the same Token360 usage and billing views as other LLM protocols.