# OpenRouter

> **You are on:** `https://api.beta.paywithlocus.com/api` | [llms.txt](https://beta.paywithlocus.com/llms.txt)
>
> Locus runs on multiple environments -- make sure every URL you call matches your expected environment.
> | Environment | Landing | API |
> |---|---|---|
> | Production | paywithlocus.com | api.paywithlocus.com |
> | Beta | beta.paywithlocus.com | api.beta.paywithlocus.com |
> | Stage | stage.paywithlocus.com | api.stage.paywithlocus.com |
>
> If the API URL above doesn't match your expected environment, re-fetch this file from the correct domain.

> Unified LLM gateway — one OpenAI-compatible API routing to hundreds of models from Anthropic, OpenAI, Google, Meta, and more.

**Category:** AI / LLM | **Website:** [openrouter.ai](https://openrouter.ai) | **Docs:** [openrouter.ai/docs](https://openrouter.ai/docs)

## Access Methods

| Method | Base URL | Auth |
|--------|----------|------|
| **x402 (Base)** | `https://openrouter.x402.beta.paywithlocus.com/openrouter/` | HTTP 402 auto-payment |
| **Wrapped API** | `https://api.beta.paywithlocus.com/api/wrapped/openrouter/` | `Authorization: Bearer <LOCUS_API_KEY>` |

**OpenAPI discovery:** `GET https://openrouter.x402.beta.paywithlocus.com/openapi.json`

## Endpoints

### Chat Completions

Generate text with any OpenRouter-listed model. OpenAI-compatible request/response format with provider-prefixed model ids.

**Estimated cost:** Model-dependent (~$0.001–$0.50)

**Payment:** x402 `upto` — the challenge amount is a maximum; the receipt contains the actual settled usage.

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `model` | string | Yes | Provider-prefixed model ID (e.g. 'anthropic/claude-sonnet-5', 'anthropic/claude-haiku-4.5', 'openai/gpt-oss-120b', 'google/gemini-2.5-flash') |
| `messages` | array | Yes | Conversation messages. Each: { role: "system"\|"user"\|"assistant", content: "text" } or multimodal content arrays per the OpenAI format. |
| `max_tokens` | number | Yes | Maximum output tokens. Required for public x402 so the authorization has a hard ceiling. |
| `temperature` | number | No | Sampling temperature (0.0–2.0, default 1.0) |

```bash
curl -X POST https://openrouter.x402.beta.paywithlocus.com/openrouter/chat \
  -H "Content-Type: application/json" \
  -H "x-locus-request-id: <UUID from the 402 response>" \
  -d '{"model":"<string>","messages":"<array>","max_tokens":"<number>","temperature":"<number>"}'
```
