This guide explains how to use the OpenAI, Claude, Gemini, SD WebUI, and Admin APIs provided by Antigravity2API.
All /v1/*, /v1beta/*, and /cli/* API requests require your API key in the Authorization header (or x-api-key for Claude / key query param for Gemini):
Authorization: Bearer YOUR_API_KEY
Default base URL: http://localhost:8045
- List Models
- Chat Completions
- Function Calling (Tools)
- Multimodal Image Input
- Image Generation
- Thinking / Reasoning Models
- Gemini CLI Endpoints
- SD WebUI Compatible API
- Admin API
- SDK Examples
- Advanced Options
curl http://localhost:8045/v1/models \
-H "Authorization: Bearer sk-text"The model list is cached for 1 hour by default (configurable via cache.modelListTTL in config.json) and includes all latest Gemini 4, Gemini 3.8/3.6/3.5/3.1/3.0, Nano Banana image, Omni Flash, Gemini 2.5, specialized Gemini, and Claude models.
curl http://localhost:8045/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-text" \
-d '{
"model": "gemini-4-hydrogen",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'curl http://localhost:8045/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-text" \
-d '{
"model": "gemini-4-hydrogen",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": false
}'curl http://localhost:8045/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-text" \
-d '{
"model": "gemini-4-argon",
"messages": [{"role": "user", "content": "What is the weather in Tokyo?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather information",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"}
},
"required": ["location"]
}
}
}]
}'Supports Base64-encoded image inputs in standard OpenAI multimodal format:
curl http://localhost:8045/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-text" \
-d '{
"model": "gemini-3.8-flash",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
}
}
]
}],
"stream": true
}'- JPEG/JPG (
data:image/jpeg;base64,...) - PNG (
data:image/png;base64,...) - GIF (
data:image/gif;base64,...) - WebP (
data:image/webp;base64,...)
Generate images with Gemini Image / Nano Banana models (gemini-nano-banana-2.1, gemini-3.1-flash-image, gemini-3.1-flash-lite-image, gemini-3-pro-image, gemini-2.5-flash-image, plus -2K and -4K resolution suffixes). Generated images are returned as Markdown image links:
curl http://localhost:8045/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-text" \
-d '{
"model": "gemini-nano-banana-2.1",
"messages": [{"role": "user", "content": "Draw a cute cat in watercolor style"}],
"stream": false
}'Response Example:
{
"choices": [{
"message": {
"role": "assistant",
"content": ""
}
}]
}Notes:
- Generated images are saved under
public/images/. - Set
IMAGE_BASE_URLin.envso returned image URLs use your public domain.
| Parameter | Type | Required | Description |
|---|---|---|---|
model |
string | Yes | Model ID (e.g., gemini-4-carbon, gemini-4-hydrogen, gemini-3.8-flash) |
messages |
array | Yes | Conversation message list |
stream |
boolean | No | Enable SSE streaming (default: false) |
temperature |
number | No | Sampling temperature (default: 1) |
top_p |
number | No | Top-P nucleus sampling (default: 1) |
top_k |
number | No | Top-K sampling (default: 50) |
max_tokens |
number | No | Maximum output tokens (default: 32000) |
thinking_budget |
number | No | Thinking token budget (0 to disable, or 1024–32000, default: 1024) |
reasoning_effort |
string | No | OpenAI-compatible reasoning depth: low (1024), medium (16000), high (32000) |
response_format |
object | No | Structured output ({ "type": "json_object" }, supported on Gemini models) |
tools |
array | No | Tool definitions for Function Calling |
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1763560000,
"model": "gemini-4-hydrogen",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 20,
"total_tokens": 30
}
}data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1763560000,"model":"gemini-4-hydrogen","choices":[{"index":0,"delta":{"role":"assistant","content":"Hello"},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1763560000,"model":"gemini-4-hydrogen","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}
data: [DONE]
| HTTP Status | Meaning |
|---|---|
200 |
Success |
400 |
Invalid request parameters |
401 |
Invalid or missing API key |
429 |
Rate limit / quota exceeded |
500 |
Internal server error |
Error response format:
{
"error": {
"message": "Error description",
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}Reasoning models (such as gemini-4-carbon, gemini-4-argon, gemini-4-neon, gemini-4-hydrogen, gemini-3.8-flash, gemini-3.6-flash, gemini-3.1-pro-preview, gemini-2.5-pro, and Claude -thinking models) support controlling thinking depth:
curl http://localhost:8045/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-text" \
-d '{
"model": "gemini-4-carbon",
"messages": [{"role": "user", "content": "Explain quantum entanglement"}],
"stream": true,
"reasoning_effort": "high"
}'reasoning_effort |
thinking_budget |
Description |
|---|---|---|
low |
1024 |
Fast response for straightforward prompts (default) |
medium |
16000 |
Balanced reasoning depth |
high |
32000 |
Deep reasoning for complex tasks |
curl http://localhost:8045/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-text" \
-d '{
"model": "gemini-4-carbon",
"messages": [{"role": "user", "content": "Prove the Pythagorean theorem"}],
"stream": true,
"thinking_budget": 24000
}'Retries are configured server-side in config.json:
"other": {
"timeout": 300000,
"retryTimes": 3,
"retryIntervalMs": 10000,
"retryPollTokenWithQuota": false,
"skipProjectIdFetch": false,
"useNativeAxios": false
}retryTimes: Maximum retry attempts (default:3).retryIntervalMs: Fixed wait interval in milliseconds (default:10000).retryPollTokenWithQuota: When enabled, switches to another non-cooled-down token with remaining quota before retrying.
Thinking content is returned in the reasoning_content field (DeepSeek-compatible):
{
"choices": [{
"message": {
"role": "assistant",
"reasoning_content": "Let me think through this step by step...",
"content": "Quantum entanglement is..."
}
}]
}When Gemini CLI mode is enabled, additional endpoints are available under /cli:
GET /cli/v1/modelsPOST /cli/v1/chat/completionsPOST /cli/v1/messagesPOST /cli/v1beta/models/:model:generateContentPOST /cli/v1beta/models/:model:streamGenerateContent
Supported model modifiers on /cli/*:
- Prefixes:
fake-stream/(fake streaming),anti-truncation/(streaming anti-truncation) - Suffixes:
-maxthinking,-nothinking,-search(Google Search grounding)
Example: anti-truncation/gemini-4-hydrogen-maxthinking-search
curl http://localhost:8045/sdapi/v1/txt2img \
-H "Content-Type: application/json" \
-d '{
"prompt": "a cute cat, high quality, detailed",
"negative_prompt": "",
"steps": 20,
"width": 512,
"height": 512
}'curl http://localhost:8045/sdapi/v1/img2img \
-H "Content-Type: application/json" \
-d '{
"prompt": "enhance this image, high quality",
"init_images": ["BASE64_ENCODED_IMAGE"],
"steps": 20
}'| Endpoint | Description |
|---|---|
GET /sdapi/v1/sd-models |
List available Gemini / Nano Banana image generation models |
GET /sdapi/v1/options |
Get current SD options |
GET /sdapi/v1/samplers |
List available samplers |
GET /sdapi/v1/upscalers |
List available upscalers |
GET /sdapi/v1/progress |
Get generation progress |
Admin endpoints require a JWT token obtained via /admin/login.
curl http://localhost:8045/admin/login \
-H "Content-Type: application/json" \
-d '{
"username": "admin",
"password": "admin123"
}'# List tokens
curl http://localhost:8045/admin/tokens \
-H "Authorization: Bearer JWT_TOKEN"
# Add token
curl http://localhost:8045/admin/tokens \
-H "Content-Type: application/json" \
-H "Authorization: Bearer JWT_TOKEN" \
-d '{
"access_token": "ya29.xxx",
"refresh_token": "1//xxx",
"expires_in": 3599
}'
# Delete token
curl -X DELETE http://localhost:8045/admin/tokens/REFRESH_TOKEN \
-H "Authorization: Bearer JWT_TOKEN"# Get quotas for a token
curl http://localhost:8045/admin/tokens/REFRESH_TOKEN/quotas \
-H "Authorization: Bearer JWT_TOKEN"
# Force refresh quotas
curl "http://localhost:8045/admin/tokens/REFRESH_TOKEN/quotas?refresh=true" \
-H "Authorization: Bearer JWT_TOKEN"# Get current rotation config
curl http://localhost:8045/admin/rotation \
-H "Authorization: Bearer JWT_TOKEN"
# Update rotation strategy
curl -X PUT http://localhost:8045/admin/rotation \
-H "Content-Type: application/json" \
-H "Authorization: Bearer JWT_TOKEN" \
-d '{
"strategy": "request_count",
"requestCount": 20
}'# Get config
curl http://localhost:8045/admin/config \
-H "Authorization: Bearer JWT_TOKEN"
# Update config
curl -X PUT http://localhost:8045/admin/config \
-H "Content-Type: application/json" \
-H "Authorization: Bearer JWT_TOKEN" \
-d '{
"json": {
"defaults": {
"temperature": 0.7
}
}
}'from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8045/v1",
api_key="sk-text"
)
stream = client.chat.completions.create(
model="gemini-4-hydrogen",
messages=[{"role": "user", "content": "Hello!"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")import OpenAI from 'openai';
const openai = new OpenAI({
baseURL: 'http://localhost:8045/v1',
apiKey: 'sk-text'
});
const stream = await openai.chat.completions.create({
model: 'gemini-4-hydrogen',
messages: [{ role: 'user', content: 'Hello!' }],
stream: true
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}Controls whether thoughtSignature is forwarded to the client in config.json:
{
"other": {
"passSignatureToClient": false
}
}false(default):thoughtSignatureis omitted from responses.true:thoughtSignatureis included in streaming deltas / responses.
Controls whether leading system messages in a request are merged into SystemInstruction:
{
"other": {
"useContextSystemPrompt": false
}
}false(default): Uses only the globalSYSTEM_INSTRUCTIONenvironment variable.true: Merges consecutive leadingsystemmessages with the globalSYSTEM_INSTRUCTION.