AKBXR AI
API Reference

Chat Completions

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.akbxr.com/v1/chat/completions

Authentication

Include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

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

Message Object Format

Text Message

{
  "role": "user|assistant|system",
  "content": "Message text here"
}

Multimodal Message (Text + Image)

{
  "role": "user",
  "content": [
    {
      "type": "text",
      "text": "Describe this image"
    },
    {
      "type": "image_url",
      "image_url": {
        "url": "data:image/jpeg;base64,..."
      }
    }
  ]
}

Response Format

Standard Response

{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "Hello! How can I help you today? 😊",
        "padding": "abcdefghijklmnopqrstuvwxyz",
        "role": "assistant"
      }
    }
  ],
  "id": "chatcmpl-BsUWgXcLO95QZEJsoaLdtj9HHf9sj",
  "usage": {
    "completion_tokens": 11,
    "prompt_tokens": 8,
    "prompt_tokens_details": {
      "cached_tokens": 0
    },
    "total_tokens": 19
  },
  "model": "auto",
  "system_fingerprint": "fp_07e970ab25"
}

Streaming Response

When stream: true, responses are sent as Server-Sent Events:

data: {"choices":[],"created":0,"id":""}

data: {"choices":[{"index":0,"delta":{"content":"","role":"assistant"}}],"created":1752331931,"id":"chatcmpl-BsVsBmSED2kGgzlZFq9xLxNSkE03L","model":"auto","system_fingerprint":"fp_07e970ab25"}

data: {"choices":[{"index":0,"delta":{"content":"Hello"}}],"created":1752331931,"id":"chatcmpl-BsVsBmSED2kGgzlZFq9xLxNSkE03L","model":"auto","system_fingerprint":"fp_07e970ab25"}

data: {"choices":[{"index":0,"delta":{"content":"!"}}],"created":1752331931,"id":"chatcmpl-BsVsBmSED2kGgzlZFq9xLxNSkE03L","model":"auto","system_fingerprint":"fp_07e970ab25"}

data: {"choices":[{"index":0,"delta":{"content":" How"}}],"created":1752331931,"id":"chatcmpl-BsVsBmSED2kGgzlZFq9xLxNSkE03L","model":"auto","system_fingerprint":"fp_07e970ab25"}

data: {"choices":[{"index":0,"delta":{"content":" can"}}],"created":1752331931,"id":"chatcmpl-BsVsBmSED2kGgzlZFq9xLxNSkE03L","model":"auto","system_fingerprint":"fp_07e970ab25"}

data: {"choices":[{"index":0,"delta":{"content":" I"}}],"created":1752331931,"id":"chatcmpl-BsVsBmSED2kGgzlZFq9xLxNSkE03L","model":"auto","system_fingerprint":"fp_07e970ab25"}

data: {"choices":[{"index":0,"delta":{"content":" help"}}],"created":1752331931,"id":"chatcmpl-BsVsBmSED2kGgzlZFq9xLxNSkE03L","model":"auto","system_fingerprint":"fp_07e970ab25"}

data: {"choices":[{"index":0,"delta":{"content":" you"}}],"created":1752331931,"id":"chatcmpl-BsVsBmSED2kGgzlZFq9xLxNSkE03L","model":"auto","system_fingerprint":"fp_07e970ab25"}

data: {"choices":[{"index":0,"delta":{"content":" today"}}],"created":1752331931,"id":"chatcmpl-BsVsBmSED2kGgzlZFq9xLxNSkE03L","model":"auto","system_fingerprint":"fp_07e970ab25"}

data: {"choices":[{"index":0,"delta":{"content":"?"}}],"created":1752331931,"id":"chatcmpl-BsVsBmSED2kGgzlZFq9xLxNSkE03L","model":"auto","system_fingerprint":"fp_07e970ab25"}

data: {"choices":[{"index":0,"delta":{"content":" 😊"}}],"created":1752331931,"id":"chatcmpl-BsVsBmSED2kGgzlZFq9xLxNSkE03L","model":"auto","system_fingerprint":"fp_07e970ab25"}

data: {"choices":[{"finish_reason":"stop","index":0,"delta":{"content":null}}],"created":1752331931,"id":"chatcmpl-BsVsBmSED2kGgzlZFq9xLxNSkE03L","usage":{"completion_tokens":11,"prompt_tokens":9,"total_tokens":20},"model":"auto","system_fingerprint":"fp_07e970ab25"}

data: [DONE]

Error Responses

The API returns standard HTTP status codes and error objects:

400 Bad Request

{
  "error": {
    "message": "Invalid request format",
    "type": "invalid_request_error",
  }
}

401 Unauthorized

{
  "error": {
    "message": "Invalid API key provided",
    "type": "invalid_request_error",
  }
}

429 Too Many Requests

{
  "error": {
    "message": "Rate limit exceeded",
    "type": "requests_error",
  }
}

500 Internal Server Error

{
  "error": {
    "message": "Internal server error",
    "type": "server_error",
  }
}

Best Practices

Message Design

  • Use system messages to set behavior and context
  • Keep messages concise but provide necessary context
  • Structure conversations logically with appropriate roles

Parameter Tuning

  • Use temperature: 0-0.3 for factual, consistent responses
  • Use temperature: 0.7-1.0 for creative content

Performance

  • Enable streaming for better user experience
  • Cache responses when appropriate
  • Implement proper error handling and retries
  • Monitor token usage to optimize costs

Image Processing

  • Supported formats: JPEG, PNG, GIF, WebP
  • Maximum image size: 20MB
  • Use base64 encoding for image data
  • Consider image compression for better performance

Supported Image Formats

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

Common Use Cases

Customer Support Bot

{
  "model": "auto",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful customer support agent. Be polite and provide accurate information."
    },
    {
      "role": "user",
      "content": "I need help with my order #12345"
    }
  ],
  "temperature": 0.3
}

Content Generation

{
  "model": "auto",
  "messages": [
    {
      "role": "system",
      "content": "You are a professional content writer specializing in blog posts."
    },
    {
      "role": "user",
      "content": "Write an engaging introduction for a blog post about sustainable living"
    }
  ],
  "temperature": 0.8,
}

Code Assistant

{
  "model": "auto",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful programming assistant. Provide clear, working code examples."
    },
    {
      "role": "user",
      "content": "How do I create a REST API endpoint in Express.js?"
    }
  ],
  "temperature": 0.2
}

For more examples and advanced usage patterns, see our Examples section.