DocumentationOverview
Learnya API
Models computed in Switzerland, behind the API your code already knows.
The Learnya API follows the OpenAI format. Keep your SDK, change the URL, the key and the model name. Every request is computed in Switzerland.
curl https://api.learnya.ai/v1/chat/completions \
-H "Authorization: Bearer $LEARNYA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flash",
"messages": [
{
"role": "user",
"content": "Summarise Swiss data protection law."
}
]
}'import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.learnya.ai/v1",
api_key=os.environ["LEARNYA_API_KEY"],
)
response = client.chat.completions.create(
model="flash",
messages=[
{
"role": "user",
"content": "Summarise Swiss data protection law.",
}
],
)
print(response.choices[0].message.content)import OpenAI from "openai"
const client = new OpenAI({
baseURL: "https://api.learnya.ai/v1",
apiKey: process.env.LEARNYA_API_KEY,
})
const response = await client.chat.completions.create({
model: "flash",
messages: [
{
role: "user",
content: "Summarise Swiss data protection law.",
},
],
})
console.log(response.choices[0].message.content)import OpenAI from "openai"
const client = new OpenAI({
baseURL: "https://api.learnya.ai/v1",
apiKey: process.env.LEARNYA_API_KEY,
})
const response: OpenAI.ChatCompletion =
await client.chat.completions.create({
model: "flash",
messages: [
{
role: "user",
content: "Summarise Swiss data protection law.",
},
],
})
const answer: string | null =
response.choices[0].message.content
console.log(answer)Response
{
"id": "chatcmpl-5d0c9e2a41b7",
"object": "chat.completion",
"created": 1791633600,
"model": "learnya-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "1. Personal data is processed lawfully, in good faith and for a stated purpose.\n2. Data protection is built in by design and by default.\n3. People can access their data and have it corrected or deleted."
},
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 21, "completion_tokens": 52, "total_tokens": 73 }
}Where to start
DevelopersYour first call in five minutesA key, a request, the response read in your code.PartnersIntegrate Learnya into your productSoftware vendors, integrators and the public sector: what we build with you.Security and legalWhat happens to a requestWhere it is computed, what is logged, what never is.
The path of a request
A request leaves your server, goes through our gateway and comes back with its response. In between, everything happens in Switzerland.
- On your side Your application Calls the API from your server, with your key. Stays Your key, which the API never sends back to you.
- In Switzerland api.learnya.ai Gateway Checks the key and picks the model your plan provides. Logs The workspace, the model and the token count. Never the content.
- Data centre Learnya model Computes the response. If a server does not respond, another one takes over in Switzerland. Never Your content is not used to train a model.
- Back Response Relayed as the model writes it, streamed if you ask. Stays On your side only. The gateway does not keep it.
What the API serves
| Endpoint | For | Guide |
|---|---|---|
POST /v1/chat/completions | Chat, streaming responses, reasoning and tools | Chat |
POST /v1/embeddings | Vectors for semantic search | Embeddings |
POST /v1/assistant | Your own assistants, their threads and their runs | Create your assistant |
GET /.well-known/openid-configuration | Sign people in with their Learnya account | Sign in with Learnya |