AstraAPI
Log in

Documentation

Connect to AstraAPI

Use familiar request formats and change the base URL. AstraAPI supports the methods described below, not every method in each SDK.

Quickstart

  1. Log in to the console and fund your separate API wallet.
  2. Create a key and save its secret; it is not shown again.
  3. Choose an ID from the model catalog and send your first request.
Keep your key on the server.Do not put it in browser JavaScript, URLs, logs, or a public repository.

OpenAI format

Base URL: https://platform.astragpt.net/api/v1. Chat Completions and stateless Responses are supported. The examples use openai/gpt-6-luna; get other available IDs from GET /api/v1/models.

Python · Chat Completions
from openai import OpenAI

client = OpenAI(
    max_retries=0,
    api_key="YOUR_ASTRA_API_KEY",
    base_url="https://platform.astragpt.net/api/v1",
)

result = client.chat.completions.create(
    model="openai/gpt-6-luna",
    messages=[{"role": "user", "content": "Explain this briefly"}],
    max_tokens=512,
)
print(result.choices[0].message.content)
JavaScript · Chat Completions
import OpenAI from "openai";

const client = new OpenAI({
  maxRetries: 0,
  apiKey: process.env.ASTRA_API_KEY,
  baseURL: "https://platform.astragpt.net/api/v1",
});

const result = await client.chat.completions.create({
  model: "openai/gpt-6-luna",
  messages: [{ role: "user", content: "Explain this briefly" }],
  max_tokens: 512,
});
curl · Responses
curl https://platform.astragpt.net/api/v1/responses \
  -H "Authorization: Bearer $ASTRA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"openai/gpt-6-luna","input":"Explain this briefly","max_output_tokens":512}'

Anthropic format

For Messages, use base URL https://platform.astragpt.net/api. Pass the key as x-api-key; the SDK adds the required version header.

Python · Messages
from anthropic import Anthropic

client = Anthropic(
    max_retries=0,
    api_key="YOUR_ASTRA_API_KEY",
    base_url="https://platform.astragpt.net/api",
)

message = client.messages.create(
    model="openai/gpt-6-luna",
    max_tokens=512,
    messages=[{"role": "user", "content": "Hello!"}],
)

Model list

An authenticated model list is available in both formats.

GET /api/v1/modelsOpenAI list
GET /api/v1/modelsAnthropic list with the anthropic-version header

Streaming

Pass stream: true. The response arrives as SSE in the selected endpoint’s format. If the client disconnects, AstraAPI stops the upstream request on a best-effort basis; work already completed remains billable.

Python · stream
with client.chat.completions.stream(
    model="openai/gpt-6-luna",
    messages=[{"role": "user", "content": "Write three lines"}],
    max_tokens=512,
) as stream:
    for event in stream:
        print(event)

Function tools

Client function definitions are sent to the model. AstraAPI returns a tool call; your application executes the function and sends the result back. AstraAPI does not execute server tools or paid built-in web/search plugins at launch.

JSON · function definition
{
  "type": "function",
  "function": {
    "name": "get_weather",
    "description": "Return weather for a city",
    "parameters": {
      "type": "object",
      "properties": {"city": {"type": "string"}},
      "required": ["city"]
    }
  }
}

Usage and cost

Requests can be up to 512 KiB. A positive balance in the selected billing wallet is required to start. Usage is metered while the response streams and the actual cost is debited. Responses can contain up to 65,536 tokens within the model limit; the default is 4,096.

All rates, including 5-minute and 1-hour cache writes, are published in the JSON pricing catalog as input_cache_write and input_cache_write_1h. Long-context conditions are in pricing_rub.overrides. An unknown rate does not mean a zero price.

The non-standard usage.cost field, when present, is passed through from the provider in USD. See the actual native-wallet debit in the console; completed JSON responses also include X-Astra-Cost-Rub for compatibility.

To prevent duplicate dispatch, assign a unique Idempotency-Key to each operation and reuse it for a network retry. Reusing a consumed key returns 409 without another model call. Disable automatic SDK retries: max_retries=0 in Python and maxRetries: 0 in JavaScript. Use X-Astra-Request-ID for reconciliation. After an ambiguous disconnect, AstraAPI reconciles any completed usage before finalizing the debit.

For Chat streaming, include_usage must be true when stream_options is supplied. Responses accepts complete text history without previous_response_id, item_reference, or encrypted reasoning; function_call_output must reference a function_call from the same request.

The response keeps the selected protocol’s usage fields. Reasoning is included in output and cached tokens in input; neither is added twice. The console request log shows the actual cost at the platform’s calculation precision.

Verified saving on 24 October 2026: GPT‑6.1 Sol base input and output prices were 30% lower than GPTunneL and AI Tunnel: RUB 280 / 1,400 versus RUB 400 / 2,000 per 1 million tokens. The comparison excludes cache, long-context tiers, and personal discounts.

Errors

401

The key is missing, expired, or revoked.

402

The selected billing wallet has no positive balance.

429

The rate or concurrency limit was reached. Respect Retry-After.

501

/messages/count_tokens is not implemented yet.

For safe retries of your own operations, use a unique Idempotency-Key where supported. An inference request is not retried automatically after an ambiguous network failure.

Launch limitations

  • Text only. Input images, audio, video, and files are not accepted yet.
  • Stateless Responses. store: true, previous_response_id, retrieve, and delete are not supported.
  • No server tools. Client function tools are available; AstraAPI does not execute them for you.
  • Exact routes. Provider, fallback, credentials, and the upstream address cannot be overridden in a request.