API Reference
Code Samples
Ready-to-use code examples for the Assisters API in multiple languages
Code Samples
All examples use $ASSISTERS_API_KEY as a placeholder. Replace it with your actual key from the dashboard, or use the personalizer below.
Install the SDK
npm install @assisters/sdkyarn add @assisters/sdkpnpm add @assisters/sdkChat Completions
curl https://api.assisters.dev/v1/chat/completions \
-H "Authorization: Bearer $ASSISTERS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "assisters-chat-v1",
"messages": [{"role": "user", "content": "Hello!"}]
}'const response = await fetch('https://api.assisters.dev/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.ASSISTERS_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'assisters-chat-v1',
messages: [{ role: 'user', content: 'Hello!' }],
}),
});
const data = await response.json();
console.log(data.choices[0].message.content);import os, requests
response = requests.post(
'https://api.assisters.dev/v1/chat/completions',
headers={
'Authorization': f'Bearer {os.environ["ASSISTERS_API_KEY"]}',
'Content-Type': 'application/json',
},
json={
'model': 'assisters-chat-v1',
'messages': [{'role': 'user', 'content': 'Hello!'}],
}
)
print(response.json()['choices'][0]['message']['content'])import { AssistersClient } from '@assisters/sdk';
const client = new AssistersClient({ apiKey: process.env.ASSISTERS_API_KEY });
const completion = await client.chat.completions.create({
model: 'assisters-chat-v1',
messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(completion.choices[0].message.content);Streaming
curl https://api.assisters.dev/v1/chat/completions \
-H "Authorization: Bearer $ASSISTERS_API_KEY" \
-H "Content-Type: application/json" \
--no-buffer \
-d '{
"model": "assisters-chat-v1",
"messages": [{"role": "user", "content": "Write a haiku about coding"}],
"stream": true
}'const response = await fetch('https://api.assisters.dev/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.ASSISTERS_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'assisters-chat-v1',
messages: [{ role: 'user', content: 'Write a haiku about coding' }],
stream: true,
}),
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const lines = decoder.decode(value).split('\n');
for (const line of lines) {
if (line.startsWith('data: ') && line !== 'data: [DONE]') {
const chunk = JSON.parse(line.slice(6));
process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}
}
}import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["ASSISTERS_API_KEY"],
base_url="https://api.assisters.dev/v1",
)
stream = client.chat.completions.create(
model="assisters-chat-v1",
messages=[{"role": "user", "content": "Write a haiku about coding"}],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)import { AssistersClient } from '@assisters/sdk';
const client = new AssistersClient({ apiKey: process.env.ASSISTERS_API_KEY });
const stream = await client.chat.completions.create({
model: 'assisters-chat-v1',
messages: [{ role: 'user', content: 'Write a haiku about coding' }],
stream: true,
});
for await (const chunk of stream) {
const content = chunk.choices[0]?.delta?.content ?? '';
process.stdout.write(content);
}Embeddings
curl https://api.assisters.dev/v1/embeddings \
-H "Authorization: Bearer $ASSISTERS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "assisters-embed-v1",
"input": "The quick brown fox jumps over the lazy dog"
}'const response = await fetch('https://api.assisters.dev/v1/embeddings', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.ASSISTERS_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'assisters-embed-v1',
input: 'The quick brown fox jumps over the lazy dog',
}),
});
const data = await response.json();
console.log('Dimensions:', data.data[0].embedding.length);import os, requests
response = requests.post(
'https://api.assisters.dev/v1/embeddings',
headers={
'Authorization': f'Bearer {os.environ["ASSISTERS_API_KEY"]}',
'Content-Type': 'application/json',
},
json={
'model': 'assisters-embed-v1',
'input': 'The quick brown fox jumps over the lazy dog',
}
)
data = response.json()
print(f"Dimensions: {len(data['data'][0]['embedding'])}")import { AssistersClient } from '@assisters/sdk';
const client = new AssistersClient({ apiKey: process.env.ASSISTERS_API_KEY });
const result = await client.embeddings.create({
model: 'assisters-embed-v1',
input: 'The quick brown fox jumps over the lazy dog',
});
console.log('Dimensions:', result.data[0].embedding.length);