Setup Guideline

Build with the API

Space Router API

Space Router speaks the OpenAI and Anthropic wire formats, so existing code usually needs one change: the base URL. This page is for wiring the gateway into your own application rather than into a ready-made tool.

Gateway: https://space.stationine.com · Last checked:

Keep your API key private. Never share a real API key in screenshots, chat messages, repositories, project files, or public documents. If a key has been exposed, revoke or rotate it in Space Router and create a new one.

Put the key in the environment

Every example below reads the key from an environment variable. Do not paste a key into source code — that is how keys reach a repository, and a key in git history stays there after the line is deleted.

export SPACE_ROUTER_API_KEY=sk-your-space-router-key

On Windows PowerShell:

$env:SPACE_ROUTER_API_KEY = 'sk-your-space-router-key'

Endpoints and key groups

The key's group decides which models it can call, and the endpoint you choose has to match the library you are using.

EndpointFormatUse it with
POST /v1/messages Anthropic Messages The Anthropic SDKs, and anything that speaks Claude natively.
POST /v1/chat/completions OpenAI Chat Completions The OpenAI SDKs and the large ecosystem of OpenAI-compatible clients.
POST /v1/responses OpenAI Responses Newer OpenAI SDK code written against the Responses API.
Key groupModel slugs
GPT (group 4) gpt-6-astra, gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna, gpt-5.5, gpt-5.4, gpt-5.4-mini
Claude (group 3) claude-opus-5, claude-sonnet-5, claude-opus-4-8, claude-opus-4-7, claude-opus-4-6, claude-sonnet-4-6
Claude Fable 5 (group 5) claude-fable-5

A key only works inside its own group. A Claude key asking for gpt-5.5, or a Claude key asking for claude-fable-5, gets a hard error rather than a fallback — Fable is a separate purchase. The live catalogue is published at /models.json, which you can fetch at run time instead of hard-coding a model list.

curl

Send one of these before writing any code. If curl works and your application does not, the problem is in the application.

Anthropic Messages

curl https://space.stationine.com/v1/messages \
    -H "x-api-key: $SPACE_ROUTER_API_KEY" \
    -H "anthropic-version: 2023-06-01" \
    -H "content-type: application/json" \
    -d '{
      "model": "claude-sonnet-5",
      "max_tokens": 64,
      "messages": [{"role": "user", "content": "Reply with OK"}]
    }'

OpenAI Chat Completions

curl https://space.stationine.com/v1/chat/completions \
    -H "Authorization: Bearer $SPACE_ROUTER_API_KEY" \
    -H "content-type: application/json" \
    -d '{
      "model": "gpt-5.6-sol",
      "messages": [{"role": "user", "content": "Reply with OK"}]
    }'

OpenAI Responses

curl https://space.stationine.com/v1/responses \
    -H "Authorization: Bearer $SPACE_ROUTER_API_KEY" \
    -H "content-type: application/json" \
    -d '{
      "model": "gpt-5.6-sol",
      "input": "Reply with OK"
    }'

Add "stream": true to any of them for server-sent events.

Point an SDK at the gateway

Both official SDKs accept a base URL override, so the rest of your code is unchanged.

OpenAI SDK — Python

import os
  from openai import OpenAI

  client = OpenAI(
      api_key=os.environ["SPACE_ROUTER_API_KEY"],
      base_url="https://space.stationine.com/v1",
  )

  response = client.chat.completions.create(
      model="gpt-5.6-sol",
      messages=[{"role": "user", "content": "Reply with OK"}],
  )
  print(response.choices[0].message.content)

OpenAI SDK — Node

import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: process.env.SPACE_ROUTER_API_KEY,
    baseURL: "https://space.stationine.com/v1",
  });

  const response = await client.chat.completions.create({
    model: "gpt-5.6-sol",
    messages: [{ role: "user", content: "Reply with OK" }],
  });
  console.log(response.choices[0].message.content);

Anthropic SDK — Python

The Anthropic SDK appends /v1/messages itself, so its base URL is the gateway root with no /v1 suffix.

import os
  from anthropic import Anthropic

  client = Anthropic(
      api_key=os.environ["SPACE_ROUTER_API_KEY"],
      base_url="https://space.stationine.com",
  )

  message = client.messages.create(
      model="claude-sonnet-5",
      max_tokens=64,
      messages=[{"role": "user", "content": "Reply with OK"}],
  )
  print(message.content[0].text)

Troubleshooting

What you seeWhat it means
401 or 403 The key is wrong, revoked, or out of balance. Check that the environment variable is actually set in the process you are running — an exported variable does not reach a shell that was already open.
404 A doubled or missing /v1. The OpenAI SDKs want the base URL to end at /v1; the Anthropic SDK wants the bare root.
The model is rejected as unknown The slug is misspelled, or it belongs to a group your key does not have. Fetch /models.json and compare.
Works in curl, fails in the app The application is not reading the same key or the same base URL. Print the base URL it resolved — never print the key.

What is Space Router?

Space Router is an AI API relay operated by Station Nine. Its base URL is https://space.stationine.com. It accepts Anthropic Messages requests at POST /v1/messages, OpenAI Chat Completions requests at POST /v1/chat/completions, and OpenAI Responses requests at POST /v1/responses, and it provides OpenAI GPT and Anthropic Claude model families. See the full Space Router overview for service and account details.