Match the unit to the workload
Chat models are typically priced by input/output tokens. Other models may use images, seconds, characters or requests. Read the model’s price unit rather than assuming every endpoint is token-priced.
A shared entry point for language, image, video and audio workflows. Choose an available model, copy a request, and understand authentication, streaming and usage.
The API at a glance
Start with a chat request, then use the same credentials for the capabilities your application needs. Every example is illustrative and runs only in your own environment.
https://api.allgate.ai/v1 Include /v1 once for OpenAI clients. HTTP request paths below are appended to this base URL.
/v1/chat/completions model gemini-4-argonStart
Create a key, set your environment and choose a model from the current catalogue. Start with a small request before adding streaming or media.
1. Set the environment
export ALLGATE_BASE_URL='https://api.allgate.ai/v1'
export ALLGATE_API_KEY='YOUR_API_KEY'This selector updates the chat, Responses, Messages and streaming examples. Your key and account must also permit access to the model.
Model catalogue3. Send a request
curl --fail-with-body --silent --show-error "$ALLGATE_BASE_URL/chat/completions" \
-H "Authorization: Bearer $ALLGATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-4-argon",
"messages": [
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Hello, Allgate"}
]
}'Python examples use httpx (pip install httpx), SDK examples use openai (pip install openai / npm install openai). Node.js examples use modern Node.js with built-in fetch.
Authentication
Every compatible-gateway request is authenticated with an API key. Keys are bound to a user and quota, and can be created, rotated or revoked at any time.
Create one on the Keys page. The full secret is shown once on creation or rotation — store it in your secret manager immediately.
Authorization: Bearer YOUR_API_KEYOpenAI SDK base_url / baseURL includes /v1. Anthropic SDK base_url / baseURL uses the API origin without /v1; its client adds /v1/messages. Tools, vision and reasoning features still depend on the selected model and upstream protocol.
Examples use Authorization: Bearer. x-api-key or api-key is also accepted when Authorization is absent. An invalid explicit Authorization header never falls back to another key header. Only the documented routes are implemented; SDK support does not imply every SDK method is available.
Chat is a useful starting point. Responses and Messages provide different request and SSE formats; validate optional features when changing models.
Endpoint reference
Core fields, copyable requests and example response shapes for each capability. Protocol support is separate from model supply; GET /v1/models is the final list visible to your key.
Endpoint support and model availability are separate. The public catalogue is not your key’s permission list.
A placeholder remains when no suitable model is available. Do not send it as a real model id.
The recommended starting point for OpenAI-compatible chat. JSON and SSE responses are supported; multimodal input, tool calls and reasoning parameters depend on the selected model.
21 available catalogue models in this category
/v1/chat/completions Create a chat completion (JSON or SSE stream)
modelstring · Requiredmessagesobject[] · Requiredstreamboolean · Optionalmax_tokensinteger · OptionalCore fields are listed here; optional provider parameters and supported values depend on the selected model.
curl --fail-with-body --silent --show-error "$ALLGATE_BASE_URL/chat/completions" \
-H "Authorization: Bearer $ALLGATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-4-argon",
"messages": [
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Hello, Allgate"}
]
}'{
"id": "chatcmpl-01a14b8e3c9d71f2a1b2c3d4e5f6",
"object": "chat.completion",
"created": 1792269000,
"model": "gemini-4-argon",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Allgate is a unified model gateway…"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 22,
"completion_tokens": 509,
"total_tokens": 531
}
}Notes
Native OpenAI Responses preserves the provider request shape. Other channels translate a stateless full conversation through Chat Completions. Translation rejects previous_response_id, conversation, item_reference, stored or background responses, built-in tools and file inputs with 400 before calling the supplier.
21 available catalogue models in this category
/v1/responses Create a response (JSON or Responses SSE)
modelstring · Requiredinputstring | object[] · Requiredinstructionsstring · Optionalmax_output_tokensinteger · Optionalstreamboolean · OptionalCore fields are listed here; optional provider parameters and supported values depend on the selected model.
curl --fail-with-body --silent --show-error "$ALLGATE_BASE_URL/responses" \
-H "Authorization: Bearer $ALLGATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-4-argon",
"input": "Explain Allgate in one sentence, then give me three key points."
}'{
"id": "resp_01a14b8e44aa71c2b4d7f0e1a2b3c4d5",
"object": "response",
"created_at": 1792269000,
"status": "completed",
"model": "gemini-4-argon",
"output": [
{
"type": "message",
"id": "msg_01a14b8e44ab72d3c5e8f1a2b3c4d5e6",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "Allgate is one gateway for every model capability…",
"annotations": []
}
]
}
],
"output_text": "Allgate is one gateway for every model capability…",
"usage": {
"input_tokens": 22,
"output_tokens": 509,
"total_tokens": 531
}
}Notes
The Anthropic Messages format. Native Anthropic channels preserve the dialect; compatible channels may translate to Chat Completions, with model-specific feature support.
21 available catalogue models in this category
/v1/messages Create a message (JSON or Anthropic SSE)
modelstring · Requiredmessagesobject[] · Requiredmax_tokensinteger · Requiredsystemstring | object[] · Optionalstreamboolean · OptionalCore fields are listed here; optional provider parameters and supported values depend on the selected model.
curl --fail-with-body --silent --show-error "$ALLGATE_BASE_URL/messages" \
-H "Authorization: Bearer $ALLGATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-4-argon",
"max_tokens": 512,
"system": "You are Allgate, a concise assistant.",
"messages": [
{"role": "user", "content": "Explain Allgate in one sentence."}
]
}'{
"id": "msg_01a14b8e52bb73e4d6f901a2b3c4d5e6",
"type": "message",
"role": "assistant",
"model": "gemini-4-argon",
"content": [
{ "type": "text", "text": "Allgate is one OpenAI-compatible gateway in front of every model vendor." }
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": { "input_tokens": 22, "output_tokens": 24 }
}Notes
Turn text into vectors for search, clustering and RAG. OpenAI-shaped embeddings request and response.
No active catalogue model in this category. These examples document the request format; a model must be enabled before you can call it.
/v1/embeddings Create text embeddings (dimensions and base64 supported)
modelstring · Requiredinputstring | string[] · Requireddimensionsinteger · OptionalCore fields are listed here; optional provider parameters and supported values depend on the selected model.
curl --fail-with-body --silent --show-error "$ALLGATE_BASE_URL/embeddings" \
-H "Authorization: Bearer $ALLGATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_EMBEDDING_MODEL",
"input": ["Allgate gateway", "openai compatible gateway"]
}'{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0123, -0.0456, 0.0789]
},
{
"object": "embedding",
"index": 1,
"embedding": [0.0234, -0.0567, 0.0891]
}
],
"model": "YOUR_EMBEDDING_MODEL",
"usage": { "prompt_tokens": 6, "total_tokens": 6 }
}Notes
Generate images from a prompt. Output sizes, formats and optional parameters depend on the provider and model.
2 available catalogue models in this category
/v1/images/generations Generate images (url or b64_json)
Model names use official IDs published by the backend. Resolution, duration and quantity are separate request parameters.
| Field | Enabled values | Default |
|---|---|---|
nNumber of images | 1 … 10 (step 1) | 1 |
sizeImage dimensions | 1024x1024 · 1536x1024 · 1024x1536 | 1024x1024 |
qualityImage quality | auto · low · medium · high | auto |
output_formatImage format | png · webp · jpeg | png |
The table and examples read catalog.generation.parameters from the public catalogue. These are commercially enabled workflows; other official model capabilities may not be enabled. GET /api/v1/public/models supplies these settings. Separately use GET /v1/models for the IDs accessible to your key.
Model catalogue ↗modelstring · Requiredpromptstring · RequiredCore fields are listed here; optional provider parameters and supported values depend on the selected model.
# Submit once; a lost response is not permission to repeat a paid POST.
curl --fail-with-body --silent --show-error "$ALLGATE_BASE_URL/images/generations" \
-H "Authorization: Bearer $ALLGATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2.5-flare",
"prompt": "A sculptural glass sphere above a calm silver sea",
"n": 1,
"size": "1024x1024",
"quality": "auto",
"output_format": "png"
}'{
"created": 1792269000,
"data": [
{
"b64_json": "BASE64_IMAGE_BYTES"
}
],
"model": "gpt-image-2.5-flare"
}Notes
Text-to-speech and speech-to-text. Speech returns binary audio; transcription accepts a multipart/form-data upload.
No active catalogue model in this category. These examples document the request format; a model must be enabled before you can call it.
Audio includes separate speech and transcription endpoints. An audio catalogue entry alone does not imply support for both.
/v1/audio/speech Text-to-speech (binary audio response)
/v1/audio/transcriptions Speech-to-text (multipart upload → JSON/text/SRT/VTT)
modelstring · Requiredinput · speechstring · Requiredvoice · speechstring · Requiredfile · transcriptionbinary · Requiredresponse_formatstring · OptionalCore fields are listed here; optional provider parameters and supported values depend on the selected model.
# text-to-speech: the response body is audio, not JSON
curl --fail-with-body --silent --show-error "$ALLGATE_BASE_URL/audio/speech" \
-H "Authorization: Bearer $ALLGATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_SPEECH_MODEL","input":"Hello, Allgate","voice":"alloy","response_format":"mp3"}' \
-o speech.mp3# speech-to-text: multipart/form-data upload
curl --fail-with-body --silent --show-error "$ALLGATE_BASE_URL/audio/transcriptions" \
-H "Authorization: Bearer $ALLGATE_API_KEY" \
-F model='YOUR_TRANSCRIPTION_MODEL' \
-F response_format=json \
-F file=@sample.wavHTTP/1.1 200 OK
content-type: audio/mpeg
x-allgate-request-id: req_01a14b8e6a2d75c4d6e7f8a9b0c1d2e3
x-allgate-model: YOUR_SPEECH_MODEL
<binary audio bytes; Content-Type follows the provider response>{
"text": "Welcome to Allgate.",
"task": "transcribe",
"language": "en",
"duration": 1.25,
"segments": [
{ "id": 0, "start": 0.0, "end": 1.25, "text": "…" }
]
}Notes
Video generation is asynchronous: create a task, then poll until succeeded / failed. Synchronous and asynchronous vendors share the same task semantics.
3 available catalogue models in this category
Create → save the task id → poll → read the result
queued → running → succeeded / failed / cancelled202 means accepted into the queue, not that a video has been generated. Poll using a key belonging to the task owner; unknown and foreign task ids return 404.
/v1/videos/generations Create a video generation task (202 Accepted)
/v1/videos/generations/{id} Poll task status and result
Model names use official IDs published by the backend. Resolution, duration and quantity are separate request parameters.
| Field | Enabled values | Default |
|---|---|---|
durationDuration / seconds | 4 … 15 (step 1) | 5 |
resolutionOutput resolution | 720p | 720p |
ratioAspect ratio | 16:9 · 9:16 · 1:1 | 16:9 |
generate_audioGenerate audio | false | false |
output_formatVideo format | mp4 | mp4 |
The table and examples read catalog.generation.parameters from the public catalogue. These are commercially enabled workflows; other official model capabilities may not be enabled. GET /api/v1/public/models supplies these settings. Separately use GET /v1/models for the IDs accessible to your key.
Image input: true · Last-frame input: true. A last frame also requires a first frame. Each capability must be true before use.
Model catalogue ↗modelstring · Requiredpromptstring · RequiredCore fields are listed here; optional provider parameters and supported values depend on the selected model.
# Submit once; a lost response is not permission to repeat a paid POST.
curl --fail-with-body --silent --show-error "$ALLGATE_BASE_URL/videos/generations" \
-H "Authorization: Bearer $ALLGATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedance-2-0-fast",
"prompt": "A sculptural glass sphere above a calm silver sea",
"duration": 5,
"resolution": "720p",
"ratio": "16:9",
"generate_audio": false,
"output_format": "mp4"
}'
# Save the returned id. Resume this GET after a connection loss.
TASK_ID='YOUR_TASK_ID'
curl --fail-with-body --silent --show-error "$ALLGATE_BASE_URL/videos/generations/$TASK_ID" \
-H "Authorization: Bearer $ALLGATE_API_KEY"HTTP/1.1 202 Accepted
{
"id": "01a14b8e7b3c74d5e6f7a8b9c0d1e2f3",
"object": "video.generation",
"status": "queued",
"model": "doubao-seedance-2-0-fast",
"created": 1792269000,
"progress": 0,
"prompt": "A sculptural glass sphere above a calm silver sea"
}{
"id": "01a14b8e7b3c74d5e6f7a8b9c0d1e2f3",
"object": "video.generation",
"status": "succeeded",
"model": "doubao-seedance-2-0-fast",
"created": 1792269000,
"completed": 1792269005,
"progress": 100,
"prompt": "A sculptural glass sphere above a calm silver sea",
"result": {
"url": "https://media.example.com/private-video.mp4",
"duration_secs": 5
}
}Notes
Create and retrieve video tasks on Allgate with the official ARK request structure and Python SDK. It shares tasks, permissions and settlement with the /v1 video API.
/api/v3/contents/generations/tasks Create a task; 200 returns {id}
/api/v3/contents/generations/tasks/{id} Retrieve an owned task and its private result URL
ARK base_url is the API origin + /api/v3; OpenAI clients use /v1. Both use your Allgate Bearer key. Do not combine these path prefixes. The Python example uses arkruntime.Ark with automatic retries disabled.
Model names use official IDs published by the backend. Resolution, duration and quantity are separate request parameters.
| Field | Enabled values | Default |
|---|---|---|
durationDuration / seconds | 4 … 15 (step 1) | 5 |
resolutionOutput resolution | 720p | 720p |
ratioAspect ratio | 16:9 · 9:16 · 1:1 | 16:9 |
generate_audioGenerate audio | false | false |
output_formatVideo format | mp4 | mp4 |
The table and examples read catalog.generation.parameters from the public catalogue. These are commercially enabled workflows; other official model capabilities may not be enabled. GET /api/v1/public/models supplies these settings. Separately use GET /v1/models for the IDs accessible to your key.
Image input: true · Last-frame input: true. A last frame also requires a first frame. Each capability must be true before use.
Model catalogue ↗modelcontentresolution · ratio · durationgenerate_audio · watermark · camera_fixed · seed · service_tier · output_formatreturn_last_framecallback_url, draft/draft_task, video or audio references, editing, adaptive duration (-1), unconfigured service tiers and other unpriced options are not enabled. Unsupported fields fail explicitly rather than being ignored.
Retrieve with the task id returned by Allgate. Keys belonging to the same user can resume retrieval; unknown and foreign tasks both return 404. content.video_url is a private result link. Use it as returned and retrieve the task again to refresh the URL.
A 200 creation response means accepted, not completed. Save the id and poll queued / running until succeeded / failed / cancelled. Resume GET after a connection loss; do not automatically repeat a paid POST with an unknown outcome.
export ALLGATE_ARK_BASE_URL='https://api.allgate.ai/api/v3'
# Submit once; a lost response is not permission to repeat a paid POST.
curl --fail-with-body --silent --show-error "$ALLGATE_ARK_BASE_URL/contents/generations/tasks" \
-H "Authorization: Bearer $ALLGATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedance-2-0-fast",
"content": [
{
"type": "text",
"text": "A sculptural glass sphere above a calm silver sea"
}
],
"duration": 5,
"resolution": "720p",
"ratio": "16:9",
"generate_audio": false,
"output_format": "mp4"
}'
# Save the returned id. Resume this GET after a connection loss.
TASK_ID='YOUR_TASK_ID'
curl --fail-with-body --silent --show-error "$ALLGATE_ARK_BASE_URL/contents/generations/tasks/$TASK_ID" \
-H "Authorization: Bearer $ALLGATE_API_KEY"{
"id": "01a14b8e7b3c74d5e6f7a8b9c0d1e2f3"
}{
"id": "01a14b8e7b3c74d5e6f7a8b9c0d1e2f3",
"model": "doubao-seedance-2-0-fast",
"status": "succeeded",
"created_at": 1792269000,
"updated_at": 1792269005,
"resolution": "720p",
"ratio": "16:9",
"duration": 5,
"generate_audio": false,
"content": {
"video_url": "https://media.example.com/private-video.mp4"
}
}Organize media in your library and reference persistent asset://IDs in code. Authentication depends on the channel: official ARK uses AK/SK signing for materials; Letsllm native ARK uses your Allgate Bearer API key.
POST https://api.allgate.ai/?Action=CreateAsset&Version=2024-01-01For official ARK material requests, use AK/SK HMAC-SHA256 signing, Region=cn-beijing and Service=ark. Create native credentials bound to your own API key in the signed-in asset library.
POST https://api.allgate.ai/api/v3/contents/generations/tasksFor Letsllm native ARK materials and video generation, use Authorization: Bearer <Allgate API key>. Official ARK material requests use separate AK/SK credentials.
| Action | Purpose |
|---|---|
CreateAssetGroup | Create an AIGC group |
GetAssetGroup | Get a group |
ListAssetGroups | Filter and paginate groups |
UpdateAssetGroup | Update name and description |
DeleteAssetGroup | Delete a group and its assets |
CreateAsset | Import an asset asynchronously from a public URL |
GetAsset | Get status and a temporary preview URL |
ListAssets | Paginate by group, name and status |
UpdateAsset | Update an asset name |
DeleteAsset | Delete an asset |
CreateVisualValidateSession | Start real-person H5 verification |
GetVisualValidateResult | Verify the result and obtain the person group |
Save the AK/SK shown once in the library. This example creates an AIGC group, imports an image and polls its real state. It does not repeat an uncertain create.
pip install volcengine-python-sdkimport os, time
import volcenginesdkcore
config = volcenginesdkcore.Configuration()
config.host = "api.allgate.ai"
config.scheme = "https"
config.region = "cn-beijing"
config.ak = os.environ["ALLGATE_ARK_AK"]
config.sk = os.environ["ALLGATE_ARK_SK"]
config.auto_retry = False # do not repeat a create with an unknown outcome
client = volcenginesdkcore.ApiClient(config)
project = os.environ.get("ALLGATE_ARK_PROJECT", "default")
def call(action, body):
reply = client.call_api(
f"/{action}/2024-01-01/ark/post/application_json/", "POST",
path_params={}, query_params=[],
header_params={"Content-Type": "application/json"},
body={**body, "ProjectName": project}, post_params=[], files={},
response_type="object", auth_settings=["volcengineSign"],
_return_http_data_only=True, collection_formats={})
if "Error" in reply["ResponseMetadata"]:
raise RuntimeError(reply["ResponseMetadata"]["Error"])
return reply["Result"]
group_id = call("CreateAssetGroup", {
"Name": "Product references", "GroupType": "AIGC"})["Id"]
asset_id = call("CreateAsset", {
"GroupId": group_id, "AssetType": "Image",
"Name": "Product image", "URL": os.environ["PUBLIC_IMAGE_URL"]})["Id"]
deadline = time.monotonic() + 300
while time.monotonic() < deadline:
asset = call("GetAsset", {"Id": asset_id})
if asset["Status"] == "Active":
print(f"asset://{asset_id}")
break
if asset["Status"] == "Failed":
raise RuntimeError("Asset processing failed; inspect GetAsset.")
time.sleep(3)
else:
raise TimeoutError("Still processing; keep the asset ID and query again.")ListAssets / ListAssetGroups require Filter.GroupType. Prefer MaxResults (1–100) with NextToken. A next token appears only when another page exists; keep the same filters. PageNumber / PageSize are also supported together and cannot be mixed with cursor parameters. Results contain only objects owned by your account.
{
"ProjectName": "default",
"Filter": {"GroupType": "AIGC", "Statuses": ["Active"]},
"MaxResults": 20
}Call CreateVisualValidateSession with CallbackURL and ProjectName, then complete verification at H5Link. BytedToken expires in 30 minutes. Call GetVisualValidateResult after the callback to verify server-side and obtain GroupId. A resultCode or redirect alone does not prove success. LivenessFace groups are created through this official flow.
The content fragment below applies to a model with the corresponding published reference capabilities and tariff scope. Use its exact current catalogue model ID. Image, video and audio indices each follow their order in content. The studio shows supported types and limits; do not infer them from a model name.
[
{"type":"text","text":"A cinematic scene. Keep the person in image 1 and the movement in video 1."},
{"type":"image_url","image_url":{"url":"asset://YOUR_IMAGE_ID"},"role":"reference_image"},
{"type":"video_url","video_url":{"url":"asset://YOUR_VIDEO_ID"},"role":"reference_video"},
{"type":"audio_url","audio_url":{"url":"asset://YOUR_AUDIO_ID"},"role":"reference_audio"}
]Frame workflows use first_frame / last_frame and cannot mix with reference_image / reference_video / reference_audio; a last frame requires a first frame. Only Active assets are usable. Assets in one task must belong to the same configured project and channel. Assets are account-private and tasks do not fail over to another supplier account.
Re-order candidate documents by relevance to a query, with Cohere / Jina-style request and response shapes.
No active catalogue model in this category. These examples document the request format; a model must be enabled before you can call it.
/v1/rerank Rerank documents (returns relevance scores)
modelstring · Requiredquerystring · Requireddocumentsstring[] | object[] · Requiredtop_ninteger · OptionalCore fields are listed here; optional provider parameters and supported values depend on the selected model.
curl --fail-with-body --silent --show-error "$ALLGATE_BASE_URL/rerank" \
-H "Authorization: Bearer $ALLGATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_RERANK_MODEL",
"query": "Allgate model gateway",
"documents": [
"The weather is nice today",
"Allgate is a unified model gateway",
"A cat is sitting on a mat"
],
"top_n": 2
}'{
"id": "rerank-01a14b8e8c5d76f7a8b9c0d1e2f3a4b5",
"object": "rerank",
"model": "YOUR_RERANK_MODEL",
"results": [
{ "index": 1, "relevance_score": 0.792937 },
{ "index": 2, "relevance_score": 0.412108 }
],
"usage": { "prompt_tokens": 31, "total_tokens": 31 }
}Notes
List the public models available to this key and retrieve a single entry by model name.
/v1/models List available models
/v1/models/{model} Retrieve a single model
curl --fail-with-body --silent --show-error "$ALLGATE_BASE_URL/models" \
-H "Authorization: Bearer $ALLGATE_API_KEY"curl --fail-with-body --silent --show-error "$ALLGATE_BASE_URL/models/gemini-4-argon" \
-H "Authorization: Bearer $ALLGATE_API_KEY"{
"object": "list",
"data": [
{ "id": "gemini-4-argon", "object": "model", "created": 1704067200, "owned_by": "Allgate" }
]
}{
"id": "gemini-4-argon",
"object": "model",
"created": 1704067200,
"owned_by": "Allgate"
}Notes
Streaming
Set stream to true and the response becomes an incremental text/event-stream. Allgate accounts token usage and time-to-first-token when the stream ends.
Set "stream": true and send Accept: text/event-stream.
Each data: line is one incremental event; event names depend on the client dialect (three dialects below).
When the stream ends the connection closes; [DONE], message_stop and response.completed are the per-dialect terminators.
Three client dialects
OpenAI SSE
The default stream format for OpenAI-compatible endpoints; every event is a chat.completion.chunk.
chat.completion.chunk (delta.content)chat.completion.chunk (finish_reason)chat.completion.chunk (usage, optional)[DONE]curl -N "$ALLGATE_BASE_URL/chat/completions" \
-H "Authorization: Bearer $ALLGATE_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{
"model": "gemini-4-argon",
"stream": true,
"stream_options": {"include_usage": true},
"messages": [{"role": "user", "content": "Explain Allgate step by step"}]
}'Usage, TTFT and aborts
Client parsing example
Parse SSE incrementally and inspect terminal events. HTTP 200 does not guarantee success: an error event or unexpected EOF without a terminator is a failure. Delivered partial output can still incur usage.
import json
import os
import httpx
base = os.environ["ALLGATE_BASE_URL"]
headers = {"Authorization": "Bearer " + os.environ["ALLGATE_API_KEY"]}
with httpx.stream(
"POST",
base + "/chat/completions",
headers=headers,
json={
"model": "gemini-4-argon",
"stream": True,
"messages": [{"role": "user", "content": "Explain Allgate step by step"}],
},
timeout=None,
) as response:
response.raise_for_status()
for line in response.iter_lines():
if not line.startswith("data:"):
continue
payload = line[5:].strip()
if payload == "[DONE]":
break
event = json.loads(payload)
if "error" in event:
raise RuntimeError(event["error"]["message"])
choices = event.get("choices", [])
if choices:
print(choices[0].get("delta", {}).get("content", ""), end="", flush=True)Errors
OpenAI-compatible endpoints return the OpenAI error envelope; /v1/messages returns the Anthropic envelope. Messages are sanitized — keys and headers are never included.
{
"error": {
"message": "The model `unknown-model` does not exist or you do not have access to it.",
"type": "invalid_request_error",
"param": null,
"code": "model_not_found"
}
}{
"type": "error",
"error": {
"type": "not_found_error",
"message": "The model `unknown-model` does not exist or you do not have access to it."
}
}| Status | type | code | Meaning |
|---|---|---|---|
| 400 | invalid_request_error | invalid_json / invalid_model / invalid_request | Malformed request, parameters or JSON. |
| 401 | authentication_error | invalid_api_key | API key missing, invalid or revoked. |
| 402 | insufficient_quota | insufficient_balance / quota_exceeded | Insufficient balance, or this key reached its spend quota. |
| 403 | permission_error | api_key_unusable / account_disabled / activation_required | Key disabled or expired, account inactive, or account activation is required before the first request. Complete activation in Billing; activated Free and Paid have the same model capabilities. |
| 404 | invalid_request_error | model_not_found | Unknown, inactive or not in the key’s model allowlist. |
| 424 | api_error | upstream_outcome_unknown | An image or speech request has an uncertain supplier outcome. x-should-retry: false means no automatic POST retry; check request logs and supplier results first. |
| 429 | rate_limit_error | rate_limit_exceeded | RPM / TPM limit hit — retry after Retry-After. |
| 500 | server_error | internal_error | Internal gateway error; it has been logged. |
| 502 | connection_error / upstream_error | upstream_unreachable / upstream_error | Upstream failed before producing output: no charge. A stream that already delivered output can still incur usage. |
| 503 | api_error | no_available_channel | Every candidate channel is cooling down; wait for Retry-After before trying again. |
| 504 | timeout_error | upstream_timeout / request_timeout | The request exceeded a deadline. Check usage logs and any created task before retrying a generation request. |
Record x-request-id / x-allgate-request-id and check Usage logs. A request id is assigned by the server; sending your own does not provide client-side idempotency. An image or speech POST returning 424 upstream_outcome_unknown with x-should-retry: false has an uncertain supplier outcome: check logs before resubmitting. Do not retry it automatically. Task polling GETs can be retried.
Usage logs/v1/messages also returns the Anthropic envelope for authentication and rate-limit errors: {"type":"error","error":{"type":"authentication_error","message":"…"}}.
Rate limits
Activated Free and Paid accounts have the same account speed and available model capabilities, with no automatic account RPM/TPM ceiling or fixed media-task cap. Explicit key limits, spendable balance, account status and supplier capabilities still apply. Actual window limits return 429 with Retry-After.
Headers
| Header | Meaning |
|---|---|
| X-RateLimit-Limit-Requests | Request budget for the enforced key or account RPM window. |
| X-RateLimit-Remaining-Requests | Remaining requests in the current window. |
| X-RateLimit-Limit-Tokens | Estimated input-token budget for the enforced key or account TPM window. |
| X-RateLimit-Remaining-Tokens | Remaining tokens in the current window. |
| Retry-After | Seconds until the request may be retried. |
HTTP/1.1 429 Too Many Requests
Retry-After: 2
X-RateLimit-Limit-Requests: 2
X-RateLimit-Remaining-Requests: 0
X-RateLimit-Limit-Tokens: 240000
X-RateLimit-Remaining-Tokens: 239812
{
"error": {
"message": "Rate limit reached for requests per minute — retry in 2s.",
"type": "rate_limit_error",
"param": null,
"code": "rate_limit_exceeded"
}
}Respect Retry-After and use backoff with jitter. Unenforced windows omit their limit headers. The numbers above illustrate the response format; they are not plan allowances.
Production essentials
The catalogue lists public prices. Your account, model and pricing policy determine the effective rate; inspect the console for the final charge.
Chat models are typically priced by input/output tokens. Other models may use images, seconds, characters or requests. Read the model’s price unit rather than assuming every endpoint is token-priced.
Requests reserve estimated capacity before dispatch and settle measured usage. Async video settles on completion. Completed /v1 video tasks expose cost_micros; inspect usage logs for native ARK charges.
The initial hold is an estimate, not an output cap. Holds grow atomically as streaming usage increases when balance and key quota cover the increase. Only a real balance, key-quota or service-validation failure stops delivery. Delivered usage is retained and settled on completion, error or disconnect.
x-allgate-request-id identifies the gateway call; x-allgate-model and x-allgate-channel describe routed responses. x-allgate-cost-micros is available on unary responses when the cost is known, not in the initial SSE headers.
Store the task id and fetch status again to resume an async workflow. Result URLs can be temporary: use the returned URL as-is, keep signed URLs private, and retrieve task status again when you need a fresh link.
Sandbox
Allgate supports an offline sandbox channel for chat, embeddings, images, video, audio and rerank request flows. A sandbox model is callable only when an operator enables it and makes it visible to your key.
Offline demo channel
Sandbox outputs are demo data, not provider model quality. An Allgate API key is still required; catalogue visibility and account policy apply. Sandbox support is not a promise of free calls.
Sandbox model ids are examples, not an availability list. Check GET /v1/models before using them.
| Model | Capability | Output |
|---|---|---|
| allgate-sandbox-chat | Chat / streaming Markdown | Bilingual Markdown with usage and TTFT |
| allgate-sandbox-embedding | Deterministic text vectors | Float arrays or base64 vectors |
| allgate-sandbox-image | Text to image | SVG artwork file /media/… |
| allgate-sandbox-video | Async text to video | Animated SVG task result /media/… |
| allgate-sandbox-tts | Text to speech / transcription | Playable WAV (speech) / demo transcript |
| allgate-sandbox-rerank | Relevance rerank | Ranked relevance scores |
Keep credentials on your server, validate a small request and inspect its usage before increasing traffic.
Catalogue snapshot: · Public model data · Models and prices · Image and video Studio · API reference