Chat Completions
The chat completions API is the core of Jobim.ai's offering. It's fully compatible with OpenAI's API, making migration seamless.
Basic Usage
JavaScript Example
const completion = await openai.chat.completions.create({
model: 'jobim-jfactor-utility',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Hello!' }
],
});Parameters
| Parameter | Type | Description |
|---|---|---|
| model | string | ID of the model to use |
| messages | array | The messages to generate completions for |
| temperature | number | Sampling temperature (0-2) |
| max_tokens | number | Maximum tokens to generate |
| stream | boolean | Whether to stream the response |
Advanced Examples
Streaming Response
const stream = await openai.chat.completions.create({
model: 'jobim-jfactor-utility',
messages: [{ role: 'user', content: 'Tell me a story' }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}JSON Mode
const completion = await openai.chat.completions.create({
model: 'jobim-jfactor-utility',
messages: [{ role: 'user', content: 'Return data as JSON' }],
response_format: { type: 'json_object' },
});