Quickstart
1. Create a key
Sign in to the console, open API keys and create a key. You’ll see it only once: copy it right away somewhere safe, for example an environment variable.
export BEATRICE_API_KEY="bea_sk_..." 2. Your first request
curl https://api.beatriceai.it/v1/chat/completions
-H "Authorization: Bearer $BEATRICE_API_KEY"
-H "Content-Type: application/json"
-d '{
"model": "beatrice-flash",
"messages": [{ "role": "user", "content": "Hi! Introduce yourself in one sentence." }]
}' 3. With the OpenAI SDK
Just change the base URL and the key.
# pip install openai
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.beatriceai.it/v1", api_key=os.environ["BEATRICE_API_KEY"])
reply = client.chat.completions.create(
model="beatrice-flash",
messages=[{"role": "user", "content": "Hi! Introduce yourself in one sentence."}],
)
print(reply.choices[0].message.content) // npm install openai
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.beatriceai.it/v1',
apiKey: process.env.BEATRICE_API_KEY,
});
const reply = await client.chat.completions.create({
model: 'beatrice-flash',
messages: [{ role: 'user', content: 'Hi! Introduce yourself in one sentence.' }],
});
console.log(reply.choices[0].message.content); 4. Streaming
stream = client.chat.completions.create(
model="beatrice-flash",
messages=[{"role": "user", "content": "Tell me about Dante in three lines."}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="", flush=True) The model reasons before answering: its reasoning comes in the reasoning_content field, separate from content. Details in Chat completions.