Skip to content
Get API key
On this page

Quickstart

Send your first request to router.africa in a few minutes, using the SDK you already have.

Get an API key

Create a key in the dashboard under API keys. Keys start with sk-ra- and are shown once, so copy yours now and store it as an environment variable.

export ROUTER_AFRICA_API_KEY="sk-ra-..."

Install an SDK

Pick your package manager. The same package works with router.africa; there is no separate router.africa SDK.

npm install openai

Send your first request

Choose how you call the API. Every tab sends the same request to https://api.router.africa/v1.

curl https://api.router.africa/v1/chat/completions \
  -H "Authorization: Bearer $ROUTER_AFRICA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "messages": [{"role": "user", "content": "Habari! Say hello in Swahili."}]
  }'

A successful response includes the model’s reply and a usage object with the tokens used. The response header x-request-id identifies the request in your logs and in any support message.

Stream the response

Add "stream": true to receive tokens as they are generated. See Streaming for the details, including streaming with the Anthropic SDK. Ask for a final usage chunk with stream_options.include_usage.

curl https://api.router.africa/v1/chat/completions \
-H "Authorization: Bearer $ROUTER_AFRICA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "model": "openai/gpt-4o-mini",
  "stream": true,
  "stream_options": { "include_usage": true },
  "messages": [
    { "role": "system", "content": "You are a helpful assistant for a Nairobi delivery startup." },
    { "role": "user", "content": "Write a two-line status message for a delayed parcel." }
  ]
}'

# The response is a stream of server-sent events:
data: {"id":"gen-8f2c","choices":[{"delta":{"role":"assistant","content":"Your"}}]}
data: {"id":"gen-8f2c","choices":[{"delta":{"content":" parcel is on its way"}}]}
data: {"id":"gen-8f2c","choices":[{"delta":{"content":", running a little late."}}]}
data: {"id":"gen-8f2c","choices":[],"usage":{"prompt_tokens":38,"completion_tokens":21,"total_tokens":59}}
data: [DONE]

What a request costs

Requests are paid for with credits. Before a request runs, router.africa holds the credits it may need at the published rate; when it finishes, you are charged for the tokens actually used and the rest of the hold is released. You can see your balance and every request in the dashboard.

Next steps