This document provides simple API usage examples, including OpenAI-compatible API, Gemini native API, and Anthropic-compatible API formats.
curl -X POST http://localhost:7860/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"model": "gemini-2.5-flash-lite",
"messages": [
{
"role": "user",
"content": "Hello, how are you?"
}
],
"stream": false
}'curl -X POST http://localhost:7860/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"model": "gemini-2.5-flash-lite",
"messages": [
{
"role": "user",
"content": "Write a short poem about autumn"
}
],
"stream": true
}'🖼️ Generate Image Official Docs
curl -X POST http://localhost:7860/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"model": "gemini-2.5-flash-image",
"messages": [
{
"role": "user",
"content": "Generate a kitten"
}
],
"stream": false
}'curl -X POST http://localhost:7860/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"model": "gemini-2.5-flash-image",
"messages": [
{
"role": "user",
"content": "Generate a kitten"
}
],
"stream": true
}'📐 Text Embeddings Official Docs
curl -X POST http://localhost:7860/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"model": "gemini-embedding-001",
"input": "What is artificial intelligence?"
}'curl -X POST http://localhost:7860/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"model": "gemini-2.5-flash-lite",
"input": "Summarize the main idea of functional programming in 3 sentences.",
"stream": false
}'curl -X POST http://localhost:7860/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"model": "gemini-2.5-flash-lite",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "Write a short poem about autumn."
}
]
}
],
"stream": true
}'curl -X POST http://localhost:7860/v1beta/models/gemini-2.5-flash-lite:generateContent \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello, how are you?"
}
]
}
]
}'curl -X POST http://localhost:7860/v1beta/models/gemini-2.5-flash-lite:streamGenerateContent?alt=sse \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Write a short poem about autumn"
}
]
}
]
}'🖼️ Generate Image Official Docs
curl -X POST http://localhost:7860/v1beta/models/gemini-2.5-flash-image:generateContent \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Generate a kitten"
}
]
}
]
}'curl -X POST http://localhost:7860/v1beta/models/gemini-2.5-flash-image:streamGenerateContent?alt=sse \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Generate a kitten"
}
]
}
]
}'🎨 Imagen (Image Generation) Official Docs
Use the imagen series models to generate images through the :predict endpoint.
curl -X POST http://localhost:7860/v1beta/models/imagen-4.0-generate-001:predict \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"instances": [
{
"prompt": "Robot holding a red skateboard"
}
],
"parameters": {
"sampleCount": 1
}
}'Adjust sampleCount to generate multiple images at once (maximum 4).
curl -X POST http://localhost:7860/v1beta/models/imagen-4.0-generate-001:predict \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"instances": [
{
"prompt": "A futuristic city at sunset with flying cars"
}
],
"parameters": {
"sampleCount": 4
}
}'💡 Tip: Imagen responses return base64-encoded image data. Each generated image will be included in the
predictionsarray.
🎤 TTS (Text-to-Speech) Official Docs
curl -X POST http://localhost:7860/v1beta/models/gemini-2.5-flash-preview-tts:generateContent \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello, this is a text-to-speech test."
}
]
}
],
"generationConfig": {
"responseModalities": ["AUDIO"]
}
}'Available voices: Kore, Puck, Charon, Fenrir, Aoede
curl -X POST http://localhost:7860/v1beta/models/gemini-2.5-flash-preview-tts:generateContent \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello, this is a text-to-speech test."
}
]
}
],
"generationConfig": {
"responseModalities": ["AUDIO"],
"speechConfig": {
"voiceConfig": {
"prebuiltVoiceConfig": {
"voiceName": "Kore"
}
}
}
}
}'Write the dialogue in the prompt and configure multiple speaker voices using multiSpeakerVoiceConfig (up to 2 speakers).
curl -X POST http://localhost:7860/v1beta/models/gemini-2.5-flash-preview-tts:generateContent \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "TTS the following conversation between Joe and Jane:\nJoe: How are you today Jane?\nJane: I am doing great, thanks for asking!"
}
]
}
],
"generationConfig": {
"responseModalities": ["AUDIO"],
"speechConfig": {
"multiSpeakerVoiceConfig": {
"speakerVoiceConfigs": [
{
"speaker": "Joe",
"voiceConfig": {
"prebuiltVoiceConfig": {
"voiceName": "Charon"
}
}
},
{
"speaker": "Jane",
"voiceConfig": {
"prebuiltVoiceConfig": {
"voiceName": "Kore"
}
}
}
]
}
}
}
}'💡 Tip: TTS responses return base64-encoded audio data in
audio/L16;codec=pcm;rate=24000format. You need to decode and convert it to WAV format for playback.
📐 Text Embeddings Official Docs
Use the embedContent or batchEmbedContents endpoint to generate text embedding vectors.
curl -X POST http://localhost:7860/v1beta/models/gemini-embedding-001:embedContent \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"model": "models/gemini-embedding-001",
"content": {
"parts": [
{
"text": "What is artificial intelligence?"
}
]
}
}'curl -X POST http://localhost:7860/v1beta/models/gemini-embedding-001:batchEmbedContents \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"requests": [
{
"model": "models/gemini-embedding-001",
"content": {
"parts": [
{
"text": "What is artificial intelligence?"
}
]
}
}
]
}'curl -X POST http://localhost:7860/v1beta/models/gemini-embedding-001:batchEmbedContents \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key-1" \
-d '{
"requests": [
{
"model": "models/gemini-embedding-001",
"content": {
"parts": [
{
"text": "What is artificial intelligence?"
}
]
}
},
{
"model": "models/gemini-embedding-001",
"content": {
"parts": [
{
"text": "What is the difference between machine learning and deep learning?"
}
]
}
}
]
}'curl -X POST http://localhost:7860/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: your-api-key-1" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "gemini-2.5-flash-lite",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello, how are you?"
}
],
"stream": false
}'curl -X POST http://localhost:7860/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: your-api-key-1" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "gemini-2.5-flash-lite",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Write a poem about autumn"
}
],
"stream": true
}'