# The raw gateway

> proxy.alfnrl.io, the stateless OpenAI-compatible gateway, and when to use it instead of the primary endpoint.

`https://proxy.alfnrl.io/v1` is the gateway the AlphaNeural API itself calls. It is OpenAI-compatible and stateless: no threads, no routing and no cost traces.

## When to use it

Use `https://backend.alfnrl.io/v1` by default. Use the gateway for:

- **Routes the AlphaNeural API does not serve**, such as `POST /v1/embeddings` and `POST /v1/images/generations`.
- **Multi-step tool calling.** The AlphaNeural API does not keep `tool_calls` and `tool_call_id` in a thread (see [Chat completions](https://app.alphaneural.io/docs/chat-completions#limitations)); the gateway forwards your messages exactly as you send them.
- **Calls you do not want kept as a thread.** Nothing sent to the gateway is saved as a thread. The gateway does keep its own usage logs for metering, so this is not the same as nothing being stored.

## Same key, same balance

The gateway takes the same API key, sent the same way:

```http
Authorization: Bearer sk-...
```

It reaches the same models your key's scope allows, and its usage is metered against the same balance in the same way. The AlphaNeural API forwards its own model calls to this gateway with your key, so a call costs the same by either route.

## Chat completions

The standard OpenAI request and response, with no AlphaNeural fields: `thread_id`, `task_id`, `step_index`, `escalation` and `max_spend` mean nothing here, `alphaneural/auto` is not a model it serves, and the `X-Thread-Id` header has no effect. The gateway drops any parameter the chosen provider does not support rather than refusing the request.

```bash
curl https://proxy.alfnrl.io/v1/chat/completions \
  -H "Authorization: Bearer $ALPHANEURAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openrouter/openai/gpt-4o-mini",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
```

```python
import os
from openai import OpenAI

gateway = OpenAI(
    base_url="https://proxy.alfnrl.io/v1",
    api_key=os.environ["ALPHANEURAL_API_KEY"],
)

completion = gateway.chat.completions.create(
    model="openrouter/openai/gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello"}],
)
print(completion.choices[0].message.content)
```

```ts
import OpenAI from "openai";

const gateway = new OpenAI({
  baseURL: "https://proxy.alfnrl.io/v1",
  apiKey: process.env.ALPHANEURAL_API_KEY,
});

const completion = await gateway.chat.completions.create({
  model: "openrouter/openai/gpt-4o-mini",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(completion.choices[0].message.content);
```

## Embeddings and images

The gateway exposes the OpenAI routes `POST /v1/embeddings` and `POST /v1/images/generations`. They serve whichever embedding and image-generation models your key can reach. The public catalogue lists chat models only today, so for a Public key these routes have no model to serve yet; the gateway answers a model it cannot serve with its own error.

## Models

`GET https://proxy.alfnrl.io/v1/models` lists every model your key can reach, embedding, image and audio models included, in the OpenAI list format with ids only. The AlphaNeural [`GET /v1/models`](https://app.alphaneural.io/docs/models) lists the chat models only, and adds prices and capabilities.

## Paths

The gateway answers with or without the `/v1` prefix; the AlphaNeural API needs it. Keep `/v1` at the end of your base URL and switching between the two is a one-word change.
