# Quickstart

Create a key, pick an available model and send one request from your server.

`POST /v1/chat/completions`

## Set up access

Create an API key in Developer → API Keys and set it in your server environment. Eligible calls use Plan usage first. Add paid credit in Billing for calls that exceed your allowance.

### Environment

```text
export UROUTER_API_KEY="YOUR_UROUTER_API_KEY"
```

## Choose a model

Fetch the catalog, then replace YOUR_MODEL_ID in the examples with an exact returned ID. For text, check urouter.text_available and the supported parameters.

### Model catalog

```text
curl --fail --silent --show-error "https://urouter.net/gateway/v1/models?max_tokens=256"
```

## Send a request

This example limits the response to 256 tokens. The model must also support that output limit. Read the Billing page before deciding how much available credit a request needs.

### cURL

```text
curl --fail-with-body "https://urouter.net/gateway/v1/chat/completions" \
  -H "Authorization: Bearer $UROUTER_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "YOUR_MODEL_ID",
  "messages": [
    {
      "role": "user",
      "content": "Explain DNS in one sentence."
    }
  ],
  "max_tokens": 256
}'
```

### Python · OpenAI SDK

```text
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["UROUTER_API_KEY"],
    base_url="https://urouter.net/gateway/v1",
    max_retries=0,
)
response = client.chat.completions.create(
    model="YOUR_MODEL_ID",
    messages=[{"role": "user", "content": "Explain DNS in one sentence."}],
    max_tokens=256,
)
print(response.choices[0].message.content)
```

## Before shipping

Keep API keys off the client. Save x-request-id, handle incomplete responses, and disable blind retries for generation requests.

- Use Bearer authentication for inference and owned-result reads. Never put a key in a URL.
- A timeout or lost connection does not prove a request was unbilled. Check its status before starting another generation.
- Select only the fields documented here. Unsupported fields are rejected rather than silently ignored.
