Chat Completions
The Chat Completions endpoint is the core of the Serika.dev API, allowing you to generate conversational responses using state-of-the-art AI models. It is fully compatible with the OpenAI API standard.
Endpoint
POST https://api.serika.dev/api/openai/v1/chat/completions
Quick Start
The easiest way to use the API is with the official OpenAI client libraries.
from openai import OpenAI
client = OpenAI(
base_url="https://api.serika.dev/api/openai/v1",
api_key="your_api_key"
)
response = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
]
)
print(response.choices[0].message.content)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.serika.dev/api/openai/v1',
apiKey: 'your_api_key',
});
async function main() {
const chatCompletion = await client.chat.completions.create({
messages: [{ role: 'user', content: 'What is the capital of France?' }],
model: 'openai/gpt-4o-mini',
});
console.log(chatCompletion.choices[0].message.content);
}
main();
curl https://api.serika.dev/api/openai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your_api_key" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [{"role": "user", "content": "What is the capital of France?"}]
}'
Request Parameters
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
array |
Yes |
A list of messages comprising the conversation so far. |
|
string |
Yes |
The ID of the model to use. |
|
boolean |
No |
If set, partial message deltas will be sent. |
|
number |
No |
Sampling temperature (0 to 2). Higher values like 0.8 are more random. |
|
integer |
No |
The maximum number of tokens to generate. |
|
string |
No |
(Serika Specific) ID of a character to adopt a persona. |
Available Models
Advanced Features
Using Characters
To use a specific character persona, include the character_id in your request.
response = client.chat.completions.create(
model="sao10k/l3.3-euryale-70b",
messages=[{"role": "user", "content": "Hello!"}],
extra_body={"character_id": "12345"}
)
Streaming
Streaming allows you to receive the response token by token, which is useful for real-time applications.
stream = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "Write a long story."}],
stream=True
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")