# Migrating from OpenRouter

> Moving code from OpenRouter to Lykia means changing the base URL and key, checking the model ids you use against Lykia's catalog, and checking the few responses that differ.

Like OpenRouter, Lykia offers an OpenAI-compatible API, writes model ids in the same `author/model` form (`anthropic/claude-sonnet-4.5`, `openai/gpt-4o` and so on) and accepts the fallback and provider-preference fields under the same names. Lykia sends requests to providers over its own direct connections or with your own provider keys; it never uses OpenRouter at any point. Most of your code carries over line for line, but you need to check the model ids you use against Lykia's catalog.

## The three changes

1. **Base URL:** `https://api.getlykia.com/v1` instead of `https://openrouter.ai/api/v1`.
2. **API key:** your Lykia API key (`lyk-v1-…`) instead of the OpenRouter key. See the [Quickstart](https://www.getlykia.com/en/docs/quickstart).
3. **Model ids:** the format is the same, but the catalogs are different: an id is not guaranteed to be written the same way in both, and a model that is not in Lykia's catalog returns `404`. Check every id you use with [`GET /models`](https://www.getlykia.com/en/docs/api-reference/models). Lykia has no ids with a suffix such as `:free`, no aliases starting with `~` and no models starting with `openrouter/`.

**Python**

```python
import os

from openai import OpenAI

client = OpenAI(
    base_url="https://api.getlykia.com/v1",  # was: OpenRouter's base URL
    api_key=os.environ["LYKIA_API_KEY"],  # was: your OpenRouter key
    default_headers={"HTTP-Referer": "https://example.com", "X-Title": "Example Support Bot"},
)

completion = client.chat.completions.create(
    model="anthropic/claude-sonnet-4.5",  # check each id with GET /models
    messages=[{"role": "user", "content": "Draft a polite reply to a refund request."}],
    extra_body={
        "models": ["openai/gpt-4o", "google/gemini-2.5-flash"],
        "provider": {"order": ["anthropic"], "allow_fallbacks": True},
        "user": "customer-4821",
    },
)
print(completion.model, completion.choices[0].message.content)
```

**TypeScript**

```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.getlykia.com/v1", // was: OpenRouter's base URL
  apiKey: process.env.LYKIA_API_KEY, // was: your OpenRouter key
  defaultHeaders: { "HTTP-Referer": "https://example.com", "X-Title": "Example Support Bot" },
});

const completion = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-4.5", // check each id with GET /models
  messages: [{ role: "user", content: "Draft a polite reply to a refund request." }],
  models: ["openai/gpt-4o", "google/gemini-2.5-flash"],
  provider: { order: ["anthropic"], allow_fallbacks: true },
  user: "customer-4821",
} as OpenAI.Chat.ChatCompletionCreateParamsNonStreaming);

console.log(completion.model, completion.choices[0].message.content);
```

## What carries over

- **Model list format.** [`GET /models`](https://www.getlykia.com/en/docs/api-reference/models) returns the same field names (`id`, `context_length`, `architecture`, `pricing`, `supported_parameters`…), so code that reads the list keeps working. The list is per project.
- **`models`.** The list of fallback models. Lykia tries `model` first and then the list, in order. See [Model fallbacks](https://www.getlykia.com/en/docs/guides/model-fallbacks).
- **`provider`.** The `order`, `only`, `ignore`, `sort` and `allow_fallbacks` sub-fields are supported and apply to Lykia's candidates (your own provider keys first, then Lykia's direct connections to the providers). Provider ids are Lykia's own list ([`GET /providers`](https://www.getlykia.com/en/docs/api-reference/providers)); naming an id that is not on it has no effect. `sort` is accepted but does not change the order yet. See [Provider routing](https://www.getlykia.com/en/docs/guides/provider-routing).
- **`user`.** An id for your end user, stored with the request record.
- **`HTTP-Referer` and `X-Title`.** Your application's URL and name, stored with the request record. Lykia does not forward them.
- **Streaming and errors.** Streams are OpenAI-style SSE, and the error body is `{ "error": { "message", "type", "code", "status", "metadata" } }`, where `code` is a stable string such as `insufficient_credits` and the HTTP status is in `status`. An error after a stream has started is a separate event without `choices`. See [Streaming](https://www.getlykia.com/en/docs/guides/streaming) and [Errors](https://www.getlykia.com/en/docs/guides/errors).

## What is different

- **Credits lookup.** [`GET /credits`](https://www.getlykia.com/en/docs/api-reference/credits) returns your company's balance, total usage, and the amounts reserved and available, with different fields from OpenRouter's. Update any code that reads it.
- **Request record lookup.** [`GET /generation`](https://www.getlykia.com/en/docs/api-reference/generation) serves the same purpose, but its response fields differ. The same id is also in the `X-Generation-Id` response header.
- **Response `provider`.** It is Lykia's id for the provider that served the request (for example `openai`, `anthropic`, `google-ai-studio`).
- **Free models.** Lykia has no `:free` variants. Lykia decides which models are free, and there are none by default. If your code relies on free models, add credits or add your own key for the model's provider.
- **Failover.** A model is served on Lykia only by the providers that offer it; Lykia does not hand the request on to an intermediary. If no provider can serve it you get `503`; define [model fallbacks](https://www.getlykia.com/en/docs/guides/model-fallbacks) to move on to another model.
- **Other request fields.** On requests that go out with Lykia's keys, only a fixed list of body fields is passed on and the rest are dropped without an error: [What is sent to the provider](https://www.getlykia.com/en/docs/api-reference/chat-completions#what-is-sent-to-the-provider). `plugins` (web search, PDF parsing) and `web_search_options` are among the dropped fields, as are `n`, `service_tier`, `modalities` and `audio`. `transforms`, `reasoning`, `usage` and the sampling parameters are passed on. Other OpenRouter-specific features are not part of Lykia.
- **`max_tokens`.** Lykia may set or lower the output limit so that the request's cost fits the available balance, key limit or project budget, and reports the value in the `X-Max-Tokens-Applied` header. See [Output limit](https://www.getlykia.com/en/docs/api-reference/chat-completions#output-limit).
- **Endpoints.** Lykia's first release offers only the endpoints in the [API reference](https://www.getlykia.com/en/docs/api-reference/overview). If your code calls others, keep those calls on your current provider for now.

## On the account side

- **Projects.** In Lykia, API keys, budgets, routing settings and request logs belong to a project. If you run several products or environments, give each its own project. See [Projects](https://www.getlykia.com/en/docs/guides/projects).
- **Your provider keys.** Provider keys you used with OpenRouter can be added to a Lykia project. See [Bring your own key (BYOK)](https://www.getlykia.com/en/docs/guides/byok).
- **Credits.** Lykia credits are in USD and held by the company. See [Credits and billing](https://www.getlykia.com/en/docs/guides/credits-and-billing).

## Next steps

- [How Lykia works](https://www.getlykia.com/en/docs/how-it-works): how companies, projects and keys fit together.
- [Migrating from OpenAI](https://www.getlykia.com/en/docs/guides/migrate-from-openai): the fields Lykia adds to the OpenAI format.
- [API reference](https://www.getlykia.com/en/docs/api-reference/overview): every endpoint.
