---
name: voxego-gateway
description: Write or move an app's code onto the Voxego Gateway, Voxego's model API in OpenAI's shape: key in the environment, the base URL, picking a model from /models, streaming and the errors to handle. Use when someone asks to call Voxego's models from code or switch an OpenAI-style app to Voxego.
---

# Use the Voxego Gateway in code

The Gateway is Voxego's model API in OpenAI's shape: one key for every model in the catalog. Anything that speaks OpenAI's API works with it by changing the base URL and the key. This skill is for writing or moving an app's code onto it; the connector has no Gateway tools, so the person makes the key on the dashboard.

## 1. Learn the app

**Ask**, only what you can't see in the code:

- What the app sends: chat, tool calls, structured output (`response_format`), images.
- Whether it streams.
- Whether the text carries personal data, so the Shield can be turned on.
- Where the code runs. The key belongs on a server, never in a page or an app people download.

## 2. The key

**Ask** the person to make a key on the dashboard's API keys page (it starts `vxg_` and is shown once), one per app or machine, and to put it in the app's environment as `VOXEGO_KEY`. Never ask them to paste it to you.

## 3. Pick the model

`GET https://voxego.dev/api/v1/models` with the key lists every model with its context length, whether it reads images, whether the key's plan has it, and its price. `voxego-chat`, `voxego-coder` and `voxego-coworker` are Voxego's own. Pick from that list against what the app needs, and keep the id in configuration so it is one change later. Don't name models from memory.

## 4. Write the code

```
Base URL       https://voxego.dev/api/v1
Authorization  Bearer $VOXEGO_KEY
```

With OpenAI's SDK, set `baseURL` (Node) or `base_url` (Python) and the key; the rest of the code stays. `POST /chat/completions` takes `messages`, `tools`, `tool_choice`, `response_format`, `temperature`, `top_p`, `stop`, `seed`, `max_tokens`, `stream`, `stream_options` and `reasoning_effort`. Streams arrive as OpenAI's server-sent events, ending with a chunk that has `usage`.

## 5. Handle errors

Errors come in OpenAI's envelope, so the SDK raises them as usual. Handle at least:

| Status | Code | What the app does |
|---|---|---|
| 401 | `invalid_api_key` | Stop and tell the operator; the key needs replacing |
| 402 | `credits_exhausted`, `budget_exhausted`, `pool_empty` | Stop and tell the operator; the balance needs a top-up or an allocation |
| 403 | `plan_required` | The model isn't in the plan; pick another from `/models` |
| 400 | `context_length_exceeded` | Shorten the input or pick a model with a longer context |
| 429 | `rate_limit_exceeded`, `daily_limit_exceeded` | Wait for `retry-after`, then send again |
| 502 | `upstream_error` | Show the message; retrying the same request rarely helps |
| 503 | `pii_check_unavailable` | The Shield couldn't check it, so nothing was sent; retry after `retry-after` |

An account on credits alone sends 30 requests a minute (Enterprise 60); a request is at most 16 MB.

## 6. Check and hand over

Run one real request through the app. `GET /usage` shows this month's requests, tokens and spend. Tell the person what changed, the model and why, where the key lives, and that they can turn the Shield on for all requests on the dashboard's Shield page.

## Always

- The key stays on a server, in the environment; never in code, a page or a chat.
- Don't tell the person what a law requires, and don't plan their time for them.
