TextGeminiGemini.2.5.FlashOpenai.Sdk
Gemini 2.5 Flash - OpenAI SDK - Quick Start
- Call gemini-2.5-flash model using OpenAI SDK format
- Synchronous processing mode, returns conversation content in real-time
- Minimal parameters for quick start
- 💡 Need more features? Check Full API Reference
Authorization
AuthorizationstringheaderRequired
##All APIs require Bearer Token authentication## **Get API Key:** Visit [API Key Management Page](https://starmagic.ai/app/api-keys) to get your API Key **Add to request header:** ``` Authorization: Bearer YOUR_API_KEY ```
Authorization: Bearer YOUR_API_KEYRequest body
application/jsonmodelenum<gemini-2.5-flash>Required
Chat model name
"gemini-2.5-flash"messagesobject[]Required
List of chat messages
[
{
"role": "user",
"content": "Hello, introduce yourself"
}
]Response
application/json成功
Response body
idstring
Unique identifier for the chat completion
"chatcmpl-20251010015944503180122WJNB8Eid"modelstring
Model name actually used
"gemini-2.5-flash"objectenum<chat.completion>
Response type
"chat.completion"createdinteger
Creation timestamp
1760032810choicesobject[]
List of chat completion choices
[
{
"index": 0,
"message": {
"role": "assistant",
"content": "Note: This is sample code!\n\nHello! I'm pleased to introduce myself.\n\nI'm a Large Language Model, trained and developed by Google..."
},
"finish_reason": "stop"
}
]usageobject
Token usage statistics
{
"prompt_tokens": 13,
"completion_tokens": 1891,
"total_tokens": 1904,
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 13,
"audio_tokens": 0,
"image_tokens": 0
},
"completion_tokens_details": {
"text_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 1480
},
"input_tokens": 0,
"output_tokens": 0,
"input_tokens_details": null
}
