logoUNLI

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

ParameterTypeRequiredDefaultDescription
modelstringYesautoModel to use for completion. Use "auto" for automatic model selection
messagesarrayYes-Array of message objects representing the conversation
streambooleanNofalseEnable streaming responses
temperaturenumberNo0.1Temperature for sampling. Higher values make output more random

Supported Image Formats

FormatMax SizeNotes
JPEG20MBRecommended for photos
PNG20MBGood for screenshots
GIF20MBStatic images only
WebP20MBModern format