API Reference

Complete reference for the AltLLM API. Fully compatible with OpenAI SDK.

Base URL

https://altllm-api.viber.autonome.fun/v1

Authentication

All API requests require a Bearer token in the Authorization header.

Authorization: Bearer YOUR_API_KEY

Get your API key from the API Keys page.

Chat Completions

POST/v1/chat/completions

Create a chat completion with optional streaming and tool use.

Request Body

ParameterTypeRequiredDescription
modelstringYesModel ID (e.g., altllm-standard)
messagesarrayYesArray of message objects
streambooleanNoEnable streaming (default: false)
max_tokensintegerNoMaximum tokens to generate
temperaturenumberNoSampling temperature (0-2, default: 1)
top_pnumberNoNucleus sampling (0-1)
stopstring | arrayNoStop sequences
toolsarrayNoCustom tools for function calling
tool_choicestring | objectNoTool selection mode
response_formatobjectNoOutput 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://altllm-api.viber.autonome.fun/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "altllm-standard",
    "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-standard",
  "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
  }
}

Streaming

Enable real-time streaming by setting stream: true.

Stream Request

curl https://altllm-api.viber.autonome.fun/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "altllm-standard",
    "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-pro",
  "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

GET/v1/models

List all available models.

curl https://altllm-api.viber.autonome.fun/v1/models \
  -H "Authorization: Bearer YOUR_API_KEY"

Health Check

GET/health

Check API gateway health status.

curl https://altllm-api.viber.autonome.fun/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.

HeaderDescription
X-RateLimit-LimitMaximum requests per minute
X-RateLimit-RemainingRemaining requests in current window
X-RateLimit-ResetTime until rate limit resets (Unix timestamp)