Skip to content

Make your first request

Create an API key, choose a model, and connect your application in a few clear steps.

1. Create an API key

Open API keys in Router and create a key for your application. Copy the secret when it appears and store it securely; it is only shown once.

Keep the key on your server. Never put it in browser code, a public repository, or a shared screenshot.

2. Choose your model

Open the model catalog and choose a supported API edition. Check its enforced limits and current availability. A listed model does not guarantee free provider capacity.

The examples below use gemma3:1b. Replace it with the exact edition you intend to use.

3. Set your environment

Copy the base URL from Developer API. It must end in /v1.

bash
export ROUTER_BASE_URL="https://api-router.optimai.network/v1"export ROUTER_API_KEY="YOUR_ROUTER_API_KEY"

For an SDK example, install openai with pip install openai (Python) or pnpm add openai (TypeScript). Run these examples on your server or in a terminal.

4. Send a request

Start with a short text message. This example waits for the full response.

Request
curl "$ROUTER_BASE_URL/chat/completions" \  -H "Authorization: Bearer $ROUTER_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "gemma3:1b",    "messages": [      { "role": "user", "content": "Hello!" }    ]  }'

5. Read the response

A successful request returns the model’s message in choices[0].message.content. The values below are illustrative.

json
{  "model": "gemma3:1b",  "choices": [{    "index": 0,    "message": { "role": "assistant", "content": "Hello!" },    "finish_reason": "stop"  }]}

Keep building

Learn how to stream a response, or explore the full chat completions reference.