Request Format
The chat completions API allows you to generate conversational responses using advanced AI models. This endpoint is compatible with the OpenAI Chat Completions API format.
Endpoint
POST https://api.unli.dev/v1/chat/completions
Authentication
Include your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEY
Example Request
import OpenAI from "openai";
const openai = new OpenAI({
baseURL: "https://api.unli.dev/v1",
apiKey: "YOUR_API_KEY",
});
const completion = await openai.chat.completions.create({
messages: [{ role: "user", content: "Hello, AI!" }],
model: "auto",
});
console.log(completion.choices[0].message.content);
import openai
openai.api_key = "YOUR_API_KEY"
openai.api_base = "https://api.unli.dev/v1"
response = openai.ChatCompletion.create(
model="auto",
messages=[{"role": "user", "content": "Hello, AI!"}]
)
print(response.choices[0].message.content)
curl -X POST https://api.unli.dev/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "auto",
"messages": [{"role": "user", "content": "Hello, AI!"}],
"stream": false
}'
Request Format
Basic Text Completion
{
"model": "auto",
"messages": [
{
"role": "user",
"content": "Hello, how are you?"
}
]
}
Text with System Message
{
"model": "auto",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant that speaks like a pirate."
},
{
"role": "user",
"content": "Tell me about the weather"
}
],
}
Image Analysis
You can provide images as input to generation requests by providing an image as a Base64-encoded data URL
{
"model": "auto",
"messages": [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD..."
}
},
{
"type": "text",
"text": "What's in this image?"
}
]
}
]
}
Parameters
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
model | string | Yes | auto | Model to use for completion. Use "auto" for automatic model selection |
messages | array | Yes | - | Array of message objects representing the conversation |
stream | boolean | No | false | Enable streaming responses |
temperature | number | No | 0.1 | Temperature for sampling. Higher values make output more random |
Supported Image Formats
Format | Max Size | Notes |
---|---|---|
JPEG | 20MB | Recommended for photos |
PNG | 20MB | Good for screenshots |
GIF | 20MB | Static images only |
WebP | 20MB | Modern format |