API Reference
Complete reference for the AltLLM API. Fully compatible with OpenAI SDK.
Base URL
https://api.altllm.ai/v1Authentication
All API requests require a Bearer token in the Authorization header.
Authorization: Bearer YOUR_API_KEYGet your API key from the API Keys page.
Chat Completions
/v1/chat/completionsCreate a chat completion with optional streaming and tool use.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID (e.g., altllm-basic) |
messages | array | Yes | Array of message objects |
stream | boolean | No | Enable streaming (default: false) |
max_tokens | integer | No | Maximum tokens to generate |
temperature | number | No | Sampling temperature (0-2, default: 1) |
top_p | number | No | Nucleus sampling (0-1) |
stop | string | array | No | Stop sequences |
tools | array | No | Custom tools for function calling |
tool_choice | string | object | No | Tool selection mode |
response_format | object | No | Output format (e.g., JSON mode) |
Message Object
{
"role": "user" | "assistant" | "system" | "tool",
"content": "string or array",
"name": "optional tool name",
"tool_call_id": "optional tool call ID"
}Example Request
curl https://api.altllm.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "altllm-basic",
"messages": [
{"role": "system", "content": "You are a helpful crypto assistant."},
{"role": "user", "content": "What is the price of Bitcoin?"}
],
"max_tokens": 500
}'Example Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1704067200,
"model": "altllm-basic",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The current price of Bitcoin is $95,051 USD..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 50,
"total_tokens": 75
}
}Video Generation
/v1/contents/generations/tasksBusiness FlexAsyncCreate a Seedance video-generation task. Seedance is an async video model, not a chat-completions model, so the create response returns analtllm_status_tokenthat you poll until the provider finishes the video.
Create Task
curl -X POST https://api.altllm.ai/v1/contents/generations/tasks \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "altllm-flex-seedance-2.0",
"prompt": "A cinematic 6-second product reveal of a crypto analytics dashboard, smooth camera push-in, crisp UI reflections",
"duration": 6,
"resolution": "720p"
}'| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | altllm-flex-seedance-2.0 or altllm-flex-seedance-2.0-fast |
prompt | string | Yes | Video prompt passed to Seedance through OpenRouter. |
duration | number | No | Requested video duration in seconds. Used for credit estimation. |
resolution | string | No | Resolution bucket such as 480p, 720p, or 1080p. |
Poll Task Status
/v1/contents/generations/tasks/{status_token}STATUS_TOKEN="<altllm_status_token from create response>"
curl https://api.altllm.ai/v1/contents/generations/tasks/$STATUS_TOKEN \
-H "Authorization: Bearer YOUR_API_KEY"The status token is signed and bound to the creating user or API key. Store it until the video completes; Portal task history is not persisted yet.
Streaming
Enable real-time streaming by setting stream: true.
Stream Request
curl https://api.altllm.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "altllm-basic",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}'Stream Response Format
data: {"id":"chatcmpl-abc123","choices":[{"delta":{"role":"assistant"}}]}
data: {"id":"chatcmpl-abc123","choices":[{"delta":{"content":"Hello"}}]}
data: {"id":"chatcmpl-abc123","choices":[{"delta":{"content":"!"}}]}
data: {"id":"chatcmpl-abc123","choices":[{"delta":{},"finish_reason":"stop"}]}
data: [DONE]Tool Use / Function Calling
Define custom tools for the model to use. Built-in crypto tools are automatically available.
Custom Tool Definition
{
"model": "altllm-basic",
"messages": [{"role": "user", "content": "Get my portfolio for 0x123..."}],
"tools": [{
"type": "function",
"function": {
"name": "get_portfolio",
"description": "Get user's crypto portfolio",
"parameters": {
"type": "object",
"properties": {
"wallet_address": {"type": "string"}
},
"required": ["wallet_address"]
}
}
}],
"tool_choice": "auto"
}Tool Call Response
{
"choices": [{
"message": {
"role": "assistant",
"content": null,
"tool_calls": [{
"id": "call_abc123",
"type": "function",
"function": {
"name": "get_portfolio",
"arguments": "{\"wallet_address\": \"0x123...\"}"
}
}]
},
"finish_reason": "tool_calls"
}]
}List Models
/v1/modelsPublicList all available models with full metadata. No authentication required.
curl https://api.altllm.ai/v1/modelsResponse
{
"object": "list",
"data": [{
"id": "altllm-basic",
"name": "AltLLM Standard",
"created": 1704067200,
"description": "AltLLM's balanced tier for daily tasks...",
"pricing": {
"prompt": "0.0000006",
"completion": "0.0000024"
},
"context_length": 256000,
"max_output_length": 32768,
"input_modalities": ["text"],
"output_modalities": ["text"],
"supported_sampling_parameters": ["temperature", "top_p", ...],
"supported_features": ["tools", "json_mode", "streaming"]
}]
}Get Model
/v1/models/{model_id}PublicGet details for a specific model. No authentication required.
curl https://api.altllm.ai/v1/models/altllm-basicProvider Info
/v1/providerPublicGet AltLLM provider metadata and capabilities.
curl https://api.altllm.ai/v1/providerHealth Check
/healthCheck API gateway health status.
curl https://api.altllm.ai/health{
"status": "healthy",
"service": "altllm-gateway",
"version": "1.0.0"
}Rate Limits
Rate limits are applied per API key. Check response headers for current usage.
| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests per minute |
X-RateLimit-Remaining | Remaining requests in current window |
X-RateLimit-Reset | Time until rate limit resets (Unix timestamp) |