Text Generation
Sybil's text generation capabilities are powered by the Chat Completions API. This API allows you to send a list of messages to a model and receive a generated response. It is compatible with the OpenAI format, making it easy to switch or integrate.
Chat Completions API
Chat models take a series of messages as input and return a model-generated message as output. Although the format is designed for multi-turn conversations, it is also useful for single-turn tasks like code generation, summarization, and translation.
Messages and Roles
The main input is the messages parameter, which is an array of message objects. Each object has a role and content.
- System: Instructions that set the behavior of the assistant (e.g., "You are a helpful coding assistant").
- User: The message or prompt from the end user.
- Assistant: The model's response. You can also pre-fill this to provide few-shot examples.
response = client.chat.completions.create(
model="deepseek-r3",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
{"role": "user", "content": "Where was it played?"}
]
)
Code Example
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.sybil.com/v1",
apiKey: "YOUR_SYBIL_API_KEY",
});
async function main() {
const stream = await client.chat.completions.create({
model: "deepseek-r3",
messages: [{ role: "user", content: "Write a poem about the ocean." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || "");
}
}
main();