Quickstart
Make your first API call in under 5 minutes.
Aivene ships an OpenAI-compatible HTTP API. If you already use the OpenAI
SDK, point its baseURL at Aivene and you are done. If you prefer raw
fetch, every endpoint is JSON in / JSON out.
This page walks through: getting a key, calling chat completions, switching to streaming, and where to go next.
Understand billing first
Before your first call, read How billing works. Requests are not priced as a flat "per call" fee - cost depends on the model and the number of tokens in and out. Skipping this is the #1 reason new users get confused by their first invoice.
Prereqs
You need a Console account and at least one active API key. Go to Manage API Keys and click Create key.
1. Install an SDK
Any OpenAI-compatible SDK works. The official openai package is the most
common choice.
bun add openai
# or
pnpm add openai
# or
npm install openaiIf you prefer no dependency, skip this and use fetch directly.
2. Store your key
Never hard-code keys. Put them in a .env file and load via
process.env.
# .env
AIVENE_API_KEY=isk-xxxxxxxxxxxxAdd .env to .gitignore. For production, use a secret manager.
3. First chat completion
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.AIVENE_API_KEY,
baseURL: 'https://api.aivene.com/v1'
});
const res = await client.chat.completions.create({
model: 'gpt-4o-mini',
messages: [
{ role: 'system', content: 'You are concise.' },
{ role: 'user', content: 'Give me 3 startup name ideas for a coffee app.' }
]
});
console.log(res.choices[0].message.content);Same request with fetch:
const res = await fetch('https://api.aivene.com/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.AIVENE_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-4o-mini',
messages: [{ role: 'user', content: 'Hello' }]
})
}).then((r) => r.json());4. Stream the response
For chat UIs, stream tokens as they arrive instead of waiting for the full reply.
const stream = await client.chat.completions.create({
model: 'gpt-4o-mini',
stream: true,
messages: [{ role: 'user', content: 'Write a haiku about rain' }]
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}Behind the scenes this is Server-Sent Events. The stream ends with
data: [DONE].
5. Add a tool
Tools let the model call your code. Define the schema, the model decides when to invoke it.
const res = await client.chat.completions.create({
model: 'gpt-4o-mini',
messages: [{ role: 'user', content: 'What is 23 * 91?' }],
tools: [
{
type: 'function',
function: {
name: 'multiply',
description: 'Multiply two integers',
parameters: {
type: 'object',
properties: {
a: { type: 'integer' },
b: { type: 'integer' }
},
required: ['a', 'b']
}
}
}
]
});
const call = res.choices[0].message.tool_calls?.[0];
// → { id: 'call_...', function: { name: 'multiply', arguments: '{"a":23,"b":91}' } }Echo the result back as a role: 'tool' message and call again to get the
final answer.
Use the Playground
The Console ships a Playground for chat, embeddings, and images so you can prototype prompts without writing client code first.
Next steps
- Billing - required reading before you scale up. Credits vs rate limits, how cost is computed per request.
- Principles - how Aivene is designed and what guarantees you get.
- Models - pick the right model for cost, speed, and capability.
- Authentication - scoping, rotation, and key safety.
- Chat Completions reference - every field in the request schema.