eurouter-integration

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

EUrouter Integration Guide

EUrouter集成指南

You are helping a developer integrate EUrouter into their application. EUrouter is a drop-in replacement for the OpenAI API, purpose-built for EU customers requiring GDPR compliance. It routes AI requests to 10 providers through a single OpenAI-compatible API at
https://api.eurouter.ai
.
Supported providers: OpenAI, Anthropic, Mistral, Scaleway (FR), GreenPT, Microsoft Foundry, Nebius, IONOS (DE), OVHcloud (FR), AWS Bedrock.
When helping developers, always load the relevant reference files from the
references/
directory in this skill folder based on what they need. Do not load all references at once.

您正在协助开发者将EUrouter集成到他们的应用程序中。EUrouter是OpenAI API的直接替代工具,专为需要GDPR合规的欧盟客户量身打造。它通过
https://api.eurouter.ai
这个统一的OpenAI兼容API,将AI请求路由至10家提供商。
支持的提供商: OpenAI、Anthropic、Mistral、Scaleway(法国)、GreenPT、Microsoft Foundry、Nebius、IONOS(德国)、OVHcloud(法国)、AWS Bedrock。
在协助开发者时,请根据他们的需求从当前技能文件夹的
references/
目录中加载相关参考文件,不要一次性加载所有参考文件。

Authentication

身份验证

EUrouter uses API keys in the format
eur_<publicId>.<secret>
.
Send the key via either header:
  • Authorization: Bearer eur_...
  • x-api-key: eur_...
For organization-scoped requests, add:
x-org-id: <uuid>
Keys are created via
POST /api/v1/keys
and the full key is shown only once at creation. It cannot be retrieved later.

EUrouter使用格式为
eur_<publicId>.<secret>
的API密钥。
可通过以下任一请求头发送密钥:
  • Authorization: Bearer eur_...
  • x-api-key: eur_...
若要发送组织范围的请求,请添加:
x-org-id: <uuid>
密钥通过
POST /api/v1/keys
创建,完整密钥仅在创建时显示一次,后续无法找回。

Drop-in Migration from OpenAI

从OpenAI无缝迁移

EUrouter is designed as a drop-in replacement. Only two things change:
Python (openai SDK):
python
from openai import OpenAI
EUrouter被设计为直接替代工具,仅需修改两处内容:
Python(openai SDK):
python
from openai import OpenAI

Before (OpenAI direct)

之前(直接调用OpenAI)

client = OpenAI(api_key="sk-...")

client = OpenAI(api_key="sk-...")

After (EUrouter) — change base_url and api_key

之后(使用EUrouter)—— 修改base_url和api_key

client = OpenAI( base_url="https://api.eurouter.ai/api/v1", api_key="eur_YOUR_KEY_HERE" )
response = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "Hello!"}] )

**Node.js (openai SDK):**
```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.eurouter.ai/api/v1",
  apiKey: "eur_YOUR_KEY_HERE",
});

const response = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Hello!" }],
});
Important: All existing OpenAI model names work as-is (e.g.,
gpt-4o
,
claude-3-5-sonnet
,
mistral-large
). No model name changes needed when migrating.

client = OpenAI( base_url="https://api.eurouter.ai/api/v1", api_key="eur_YOUR_KEY_HERE" )
response = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "Hello!"}] )

**Node.js(openai SDK):**
```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.eurouter.ai/api/v1",
  apiKey: "eur_YOUR_KEY_HERE",
});

const response = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Hello!" }],
});
重要提示: 所有现有OpenAI模型名称可直接使用(例如
gpt-4o
claude-3-5-sonnet
mistral-large
),迁移时无需修改模型名称。

Core Endpoints

核心端点

All endpoints are prefixed with
/api
. Base URL:
https://api.eurouter.ai
EndpointMethodAuthDescription
/api/v1/chat/completions
POSTYesChat completions (streaming, tools, vision, audio, reasoning)
/api/v1/completions
POSTYesLegacy text completions
/api/v1/embeddings
POSTYesText embeddings
/api/v1/responses
POSTYesOpenAI Responses API compatible
/api/v1/models
GETNoList/filter model catalog
/api/v1/providers
GETNoList available providers
/api/v1/credits
GETYesCheck credit balance (EUR)
/api/v1/keys
CRUDYesManage API keys
/api/v1/routing-rules
CRUDYesManage named routing configs
/health
GETNoHealth check
For full endpoint schemas, load
references/endpoints.md
.

所有端点均以
/api
为前缀,基础URL:
https://api.eurouter.ai
端点请求方法需要身份验证描述
/api/v1/chat/completions
POST聊天补全(流式传输、工具调用、视觉、音频、推理)
/api/v1/completions
POST传统文本补全
/api/v1/embeddings
POST文本嵌入
/api/v1/responses
POST兼容OpenAI Responses API
/api/v1/models
GET列出/筛选模型目录
/api/v1/providers
GET列出可用提供商
/api/v1/credits
GET查看信用余额(欧元)
/api/v1/keys
CRUD管理API密钥
/api/v1/routing-rules
CRUD管理命名路由配置
/health
GET健康检查
如需完整的端点架构,请加载
references/endpoints.md

EU/GDPR Compliance

欧盟/GDPR合规

This is EUrouter's key differentiator. Add a
provider
object to any generation request to enforce compliance:
json
{
  "model": "gpt-4o",
  "messages": [{"role": "user", "content": "Hello"}],
  "provider": {
    "data_residency": "eu",
    "eu_owned": true,
    "data_collection": "deny",
    "max_retention_days": 0
  }
}
FieldTypeDescription
data_residency
string
Region code —
"eu"
,
"de"
,
"fr"
, etc. Only endpoints in that region
eu_owned
boolean
Only EU-headquartered providers (Scaleway, IONOS, OVHcloud, GreenPT, Mistral)
data_collection
"allow" | "deny"
"deny"
excludes providers that use data for training
max_retention_days
number
Max data retention.
0
= zero-data-retention only
Ready-to-use compliance profiles:
json
// Strict GDPR: EU owned, no training data, zero retention, EU hosted
{ "eu_owned": true, "data_collection": "deny", "max_retention_days": 0, "data_residency": "eu" }

// EU hosted, cheapest price
{ "data_residency": "eu", "sort": "price" }

// Specific EU providers only
{ "only": ["scaleway", "ionos", "ovhcloud"] }
For all provider preference fields, load
references/provider-preferences.md
.

这是EUrouter的核心差异化优势。在任何生成请求中添加
provider
对象即可强制合规:
json
{
  "model": "gpt-4o",
  "messages": [{"role": "user", "content": "Hello"}],
  "provider": {
    "data_residency": "eu",
    "eu_owned": true,
    "data_collection": "deny",
    "max_retention_days": 0
  }
}
字段类型描述
data_residency
string
地区代码 —
"eu"
"de"
"fr"
等,仅使用该地区的端点
eu_owned
boolean
仅选择欧盟总部的提供商(Scaleway、IONOS、OVHcloud、GreenPT、Mistral)
data_collection
"allow" | "deny"
"deny"
会排除将数据用于训练的提供商
max_retention_days
number
最大数据保留天数,
0
表示仅选择零数据保留的提供商
即用型合规配置文件:
json
// 严格GDPR合规:欧盟所有、不用于训练数据、零保留、欧盟托管
{ "eu_owned": true, "data_collection": "deny", "max_retention_days": 0, "data_residency": "eu" }

// 欧盟托管、价格最优
{ "data_residency": "eu", "sort": "price" }

// 仅指定欧盟提供商
{ "only": ["scaleway", "ionos", "ovhcloud"] }
如需查看所有提供商偏好字段,请加载
references/provider-preferences.md

Model Fallback

模型降级回退

Pass a
models
array to try multiple models in order. If all providers for the first model fail, EUrouter tries the next:
json
{
  "models": ["claude-3-5-sonnet", "gpt-4o", "mistral-large"],
  "messages": [{"role": "user", "content": "Hello"}],
  "provider": { "data_residency": "eu" }
}
Note: Model fallback is NOT supported for embeddings (vector dimensions differ between models). Only provider fallback (same model, different provider endpoint) works for embeddings.

传入
models
数组可按顺序尝试多个模型。如果第一个模型的所有提供商都请求失败,EUrouter会尝试下一个模型:
json
{
  "models": ["claude-3-5-sonnet", "gpt-4o", "mistral-large"],
  "messages": [{"role": "user", "content": "Hello"}],
  "provider": { "data_residency": "eu" }
}
注意: 模型降级回退不适用于嵌入(不同模型的向量维度不同),嵌入仅支持提供商降级回退(同一模型,不同提供商端点)。

Routing Rules

路由规则

Create reusable routing configurations to avoid repeating provider preferences on every request:
json
// Create a rule once:
// POST /api/v1/routing-rules
{
  "name": "gdpr-strict",
  "provider": {
    "eu_owned": true,
    "data_collection": "deny",
    "max_retention_days": 0,
    "data_residency": "eu"
  }
}

// Then reference it by name:
{
  "model": "gpt-4o",
  "rule_name": "gdpr-strict",
  "messages": [{"role": "user", "content": "Hello"}]
}
You can also reference by UUID with
rule_id
. Per-request
provider
preferences merge with the rule — request-level values take precedence.
Dry-run testing: Use
POST /api/v1/routing-rules/dry-run
to preview which providers satisfy a routing config without making a real request.
For full routing rules API, load
references/routing-rules.md
.

创建可复用的路由配置,避免在每个请求中重复设置提供商偏好:
json
// 一次性创建规则:
// POST /api/v1/routing-rules
{
  "name": "gdpr-strict",
  "provider": {
    "eu_owned": true,
    "data_collection": "deny",
    "max_retention_days": 0,
    "data_residency": "eu"
  }
}

// 之后通过名称引用:
{
  "model": "gpt-4o",
  "rule_name": "gdpr-strict",
  "messages": [{"role": "user", "content": "Hello"}]
}
您也可以通过UUID使用
rule_id
引用。请求级别的
provider
偏好会与规则合并,且请求级别的值优先级更高。
试运行测试: 使用
POST /api/v1/routing-rules/dry-run
可预览哪些提供商符合路由配置,无需发起真实请求。
如需完整的路由规则API,请加载
references/routing-rules.md

Model Discovery

模型发现

GET /api/v1/models
GET /api/v1/models?provider=scaleway
GET /api/v1/models?supported_parameters=tools,vision
GET /api/v1/models?category=embedding
Prices are returned as strings in the model's
pricing
object with a
currency
field. Credits are in EUR.

GET /api/v1/models
GET /api/v1/models?provider=scaleway
GET /api/v1/models?supported_parameters=tools,vision
GET /api/v1/models?category=embedding
价格会在模型的
pricing
对象中以字符串形式返回,并包含
currency
字段,信用额度以欧元为单位。

Response Headers

响应头

Every generation endpoint returns routing transparency headers:
HeaderDescription
x-provider-id
Internal provider UUID
x-provider-slug
Provider name (e.g.,
openai
,
scaleway
)
x-routing-strategy
Strategy used for routing
x-model-used
Actual model slug used
x-model-variant
Variant suffix if applicable (
:free
,
:nitro
)
x-fallback-count
Number of provider fallbacks (only present if > 0)
x-model-fallback-count
Number of model fallbacks (only present if > 0)

每个生成端点都会返回路由透明性头信息:
响应头描述
x-provider-id
提供商内部UUID
x-provider-slug
提供商名称(例如
openai
scaleway
x-routing-strategy
所使用的路由策略
x-model-used
实际使用的模型标识
x-model-variant
模型变体后缀(如有,例如
:free
:nitro
x-fallback-count
提供商降级回退次数(仅当次数>0时返回)
x-model-fallback-count
模型降级回退次数(仅当次数>0时返回)

Streaming

流式传输

Set
"stream": true
for SSE streaming. Format is OpenAI-compatible:
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"},"index":0,"finish_reason":null}]}

data: [DONE]
For usage stats in the final chunk, add
"stream_options": { "include_usage": true }
.

设置
"stream": true
即可启用SSE流式传输,格式与OpenAI兼容:
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"},"index":0,"finish_reason":null}]}

data: [DONE]
如需在最终分块中返回使用统计信息,请添加
"stream_options": { "include_usage": true }

Error Format

错误格式

All errors follow:
json
{
  "error": {
    "code": "NOT_FOUND",
    "message": "Model not found"
  },
  "requestId": "uuid"
}
Key error codes:
UNAUTHORIZED
(401),
FORBIDDEN
(403),
NOT_FOUND
(404),
BAD_REQUEST
(400),
INSUFFICIENT_QUOTA
(402),
SERVICE_UNAVAILABLE
(503).

所有错误均遵循以下格式:
json
{
  "error": {
    "code": "NOT_FOUND",
    "message": "Model not found"
  },
  "requestId": "uuid"
}
主要错误代码:
UNAUTHORIZED
(401)、
FORBIDDEN
(403)、
NOT_FOUND
(404)、
BAD_REQUEST
(400)、
INSUFFICIENT_QUOTA
(402)、
SERVICE_UNAVAILABLE
(503)。

Reference Files

参考文件

Load these based on the developer's specific need:
NeedFile
Full endpoint request/response schemas
references/endpoints.md
All provider routing preference fields
references/provider-preferences.md
Routing rules CRUD + dry-run API
references/routing-rules.md
Python code examples (openai SDK)
references/code-examples-python.md
Node.js/TypeScript code examples
references/code-examples-node.md
curl examples
references/code-examples-curl.md
根据开发者的具体需求加载以下文件:
需求文件
完整的端点请求/响应架构
references/endpoints.md
所有提供商路由偏好字段
references/provider-preferences.md
路由规则CRUD及试运行API
references/routing-rules.md
Python代码示例(openai SDK)
references/code-examples-python.md
Node.js/TypeScript代码示例
references/code-examples-node.md
curl示例
references/code-examples-curl.md