Active development · testnet

API reference

SpaceRouter API

One OpenAI-compatible endpoint for chat and image models. Use the OpenAI SDK you already have and change the base URL.

Make a request

Create a key in the app, then send your first request.

curl https://api.spacerouter.ai/v1/chat/completions \
  -H "Authorization: Bearer $SPACEROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-3.1-flash-lite",
    "messages": [{ "role": "user", "content": "Say hello" }]
  }'

Base URL

https://api.spacerouter.ai/v1

Auth

Bearer token

Format

OpenAI-compatible

The examples use google/gemini-3.1-flash-lite. Any model ID from the catalogue works in its place.

Endpoints

Paths are relative to the base URL.

MethodPathWhat it does
GET/modelsLists every model your key can use.
POST/chat/completionsSends a chat request. Set stream to true to receive server-sent events that end with [DONE].

Streaming

Add "stream": true and read the response as server-sent events. Each event carries the next piece of the answer, and the stream ends with [DONE].

curl
curl -N https://api.spacerouter.ai/v1/chat/completions \
  -H "Authorization: Bearer $SPACEROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-3.1-flash-lite",
    "messages": [{ "role": "user", "content": "Say hello" }],
    "stream": true
  }'

# data: {"object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"}}]}
# data: [DONE]

Generate an image

Image models answer through the same chat endpoint. Ask for image output with modalities, and the picture comes back as a base64 data URL on the message. Read it at choices[0].message.images[0].image_url.url.

curl
curl https://api.spacerouter.ai/v1/chat/completions \
  -H "Authorization: Bearer $SPACEROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-3.1-flash-image",
    "messages": [{ "role": "user", "content": "A friendly illustrated portrait of a person" }],
    "modalities": ["image", "text"]
  }'

# choices[0].message.images[0].image_url.url  ->  "data:image/png;base64,..."

Authentication and errors

Send your key as a Bearer token. A missing or invalid key returns status 401 with the standard error object.

HTTP 401
{
  "error": {
    "message": "The API key is missing or not valid.",
    "type": "invalid_request_error",
    "code": "invalid_api_key",
    "param": null
  }
}

Response headers

HeaderMeaning
x-sr-costThe cost of this request.
x-request-idThe request’s identifier. Quote it when you contact support.

Model IDs

IDs follow provider/model. A few forms add something to that.

FormExampleMeaning
provider/modelanthropic/claude-sonnet-5.5A specific model.
~provider/name-latest~anthropic/claude-sonnet-latestAn alias that points at the newest model of that name.
model:batchanthropic/claude-sonnet-5.5:batchThe batch variant of a model.
model:freegoogle/gemma-4-31b-it:freeThe free variant, where one is offered.

Models

A selection from the catalogue as of 23 November 2026. GET /models lists everything your key can use, and is the source of truth.

Frontier

  • anthropic/claude-fable-5.2
  • anthropic/claude-opus-5.5
  • openai/gpt-6.1-sol
  • google/gemini-3.1-pro-preview
  • x-ai/grok-4.7
  • moonshotai/kimi-k3.1-pro

Fast and low cost

  • anthropic/claude-haiku-5.5
  • google/gemini-3.1-flash-lite
  • openai/gpt-5.4-nano
  • mistralai/mistral-small-2603
  • qwen/qwen3.8-flash
  • deepseek/deepseek-v4.1-flash

Open-weight families

  • openai/gpt-oss-120b
  • meta-llama/llama-3.3-70b-instruct
  • mistralai/mistral-nemo
  • google/gemma-4-31b-it
  • nvidia/nemotron-3-super-120b-a12b

Image generation

  • google/gemini-3.1-flash-image
  • google/gemini-3-pro-image
  • openai/gpt-5-image

Search-grounded

  • perplexity/sonar-pro

Limits and pricing

Rate limits depend on your plan. Prices are set per model and change, so check the pricing page and your usage dashboard rather than a table here.

Ready to build?

What's NewSpaceRouter API reference · space-os