On this page
Why migrate to the EU Router
The EU Router is an OpenAI- and Anthropic-compatible inference gateway that runs open models on European GPUs. Your prompts and answers never leave the EU, there is no US cloud provider in the chain, and you pay per token from one prepaid credit balance. Because the API is drop-in compatible, nothing changes in your application code except the base URL and the API key.
What you need
- A HostYourAI account with some credit
- An API key in the
hyai-...format, created under Router in your dashboard - Your existing OpenAI or Anthropic SDK, no new library to install
Step 1, Create an API key
In your dashboard, go to Router and create a new key. Copy the hyai- key right away; you only see it once. This key replaces your OpenAI key.
Step 2, Point your client at the Router
Set the base URL to https://hostyourai.com/api/v1 and use your HostYourAI key. In Python with the OpenAI SDK, the rest of your code is unchanged:
from openai import OpenAI
client = OpenAI(
base_url="https://hostyourai.com/api/v1",
api_key="hyai-...", # your HostYourAI key
)
resp = client.chat.completions.create(
model="llama-3.3-70b",
messages=[{"role": "user", "content": "Summarise this contract."}],
)
print(resp.choices[0].message.content)
In Node.js with the same SDK:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://hostyourai.com/api/v1",
apiKey: process.env.HOSTYOURAI_API_KEY,
});
const resp = await client.chat.completions.create({
model: "llama-3.3-70b",
messages: [{ role: "user", content: "Summarise this contract." }],
});
console.log(resp.choices[0].message.content);
Or straight from curl to test quickly:
curl https://hostyourai.com/api/v1/chat/completions \
-H "Authorization: Bearer hyai-..." \
-H "Content-Type: application/json" \
-d '{"model":"llama-3.3-70b","messages":[{"role":"user","content":"Hello"}]}'
Step 3, Pick an open model
Where you would use gpt-4o on OpenAI, pick an open model from the Model Garden here, for example a Llama, Qwen, Mistral or DeepSeek variant. Use the model slug exactly as it appears in the Model Garden as the value for model. Streaming works identically: set stream=True and you get server-sent events back.
Using the Anthropic SDK?
That works too. The Router exposes a /v1/messages shim. Set the base URL to https://hostyourai.com and pass your hyai- key as x-api-key:
from anthropic import Anthropic
client = Anthropic(
base_url="https://hostyourai.com",
api_key="hyai-...",
)
msg = client.messages.create(
model="llama-3.3-70b",
max_tokens=512,
messages=[{"role": "user", "content": "Hello"}],
)
print(msg.content[0].text)
Step 4, Verify and go live
Test your first request in the Playground or from your code and track usage, tokens and latency per request in your activity log. Two things to watch when migrating: model names differ (use open-model slugs, not gpt-*), and you pay per token instead of via an OpenAI subscription.
Need predictable performance?
The shared Router is ideal to start with. If you want isolation or guaranteed capacity, promote a model to a dedicated instance on your own EU GPU. Your code stays identical, only the model slug or endpoint changes.
Reference: what exactly changes
This table puts the settings side by side. For more background on the gateway itself, see the EU Inference Router page.
| Setting | On OpenAI | On the EU Router |
|---|---|---|
| Base URL | https://api.openai.com/v1 | https://hostyourai.com/api/v1 |
| API key | sk-... | hyai-... |
| Model | gpt-4o, gpt-4o-mini | Open models such as Llama, Qwen, Mistral, DeepSeek or Gemma |
| Streaming | stream=true, SSE | Identical, stream=true with server-sent events |
| Anthropic route | Not applicable | /v1/messages shim, buffered streaming, text only |
| Billing | Subscription or usage billing | Pay-as-you-go per token, see pricing |
Troubleshooting
I get 401 Unauthorized
Check that your key starts with hyai- and was copied in full. An OpenAI key (sk-...) does not work on the Router. Create a fresh key under Router if needed.
My requests return 404 or never arrive
Almost always the base URL is wrong. It must be exactly https://hostyourai.com/api/v1. Make sure your SDK does not append another /v1 to the URL on its own.
The model responds slowly or seems unavailable
Not every model is permanently warm. The Model Garden shows per model whether it is warm or still warming up. Pick a warm model or wait a moment; after that, responses are fast as usual.
Streaming behaves differently through the Anthropic SDK
The /v1/messages shim uses buffered streaming and supports text only. If you need token-by-token streaming, use the OpenAI route on /api/v1/chat/completions.
Questions about this guide
Do I have to rewrite my application code?
No. You only change the base URL and the API key. Everything else, including streaming and the message structure, stays the same.
Which models can I use after migrating?
Open models such as Llama, Qwen, Mistral, DeepSeek and Gemma. The current catalogue with live status is in the Model Garden.
What does using the Router cost?
You pay per token, pay-as-you-go, from one prepaid credit balance, with no subscription. See the pricing page.
Does my data stay inside Europe?
Yes. The models run on GPUs in European datacenters and your prompts and answers never leave the EU.
Can I move to my own hardware later?
Yes. For isolation or guaranteed capacity, move a model to a dedicated GPU instance. Your key and base URL keep working.