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.
MarkdownLike 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
- Base URL:
https://api.getlykia.com/v1instead ofhttps://openrouter.ai/api/v1. - API key: your Lykia API key (
lyk-v1-…) instead of the OpenRouter key. See the Quickstart. - 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 withGET /models. Lykia has no ids with a suffix such as:free, no aliases starting with~and no models starting withopenrouter/.
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)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 /modelsreturns 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 triesmodelfirst and then the list, in order. See Model fallbacks.provider. Theorder,only,ignore,sortandallow_fallbackssub-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); naming an id that is not on it has no effect.sortis accepted but does not change the order yet. See Provider routing.user. An id for your end user, stored with the request record.HTTP-RefererandX-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" } }, wherecodeis a stable string such asinsufficient_creditsand the HTTP status is instatus. An error after a stream has started is a separate event withoutchoices. See Streaming and Errors.
What is different
- Credits lookup.
GET /creditsreturns 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 /generationserves the same purpose, but its response fields differ. The same id is also in theX-Generation-Idresponse header. - Response
provider. It is Lykia's id for the provider that served the request (for exampleopenai,anthropic,google-ai-studio). - Free models. Lykia has no
:freevariants. 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 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.
plugins(web search, PDF parsing) andweb_search_optionsare among the dropped fields, as aren,service_tier,modalitiesandaudio.transforms,reasoning,usageand 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 theX-Max-Tokens-Appliedheader. See Output limit.- Endpoints. Lykia's first release offers only the endpoints in the API reference. 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.
- Your provider keys. Provider keys you used with OpenRouter can be added to a Lykia project. See Bring your own key (BYOK).
- Credits. Lykia credits are in USD and held by the company. See Credits and billing.
Next steps
- How Lykia works: how companies, projects and keys fit together.
- Migrating from OpenAI: the fields Lykia adds to the OpenAI format.
- API reference: every endpoint.