API Documentation

Authentication

All API requests must be authenticated with an API key. You can obtain an API key from your API Keys dashboard.

import requests

api_key = "YOUR_API_KEY"
headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json"
}

response = requests.post(
    "https://api.Best-gateway.com/v1/chat",
    headers=headers,
    json={
        "messages": [
            {"role": "user", "content": "What is artificial intelligence?"}
        ]
    }
)

print(response.json())

Chat API

The Chat API provides a conversational interface to interact with the Best AI model. You can send a series of messages and receive AI-generated responses.

Request Format

POST /v1/chat
Content-Type: application/json

{
  "messages": [
    {"role": "system", "content": "You are a helpful AI assistant."}, // Optional
    {"role": "user", "content": "What is artificial intelligence?"}
  ],
  "temperature": 0.7,    // Controls randomness (0.0 to 1.0)
  "max_tokens": 1000,    // Maximum length of the response
  "stream": false        // Set to true for streaming responses
}

Response Format

{
  "id": "chat-abc123",
  "object": "chat.completion",
  "created": 1677649420,
  "model": "Best-chat",
  "usage": {
    "prompt_tokens": 56,    // Number of tokens in the prompt
    "completion_tokens": 31, // Number of tokens in the response
    "total_tokens": 87      // Total tokens used
  },
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Artificial intelligence is..."
      },
      "finish_reason": "stop", // Possible values: "stop", "length", "content_filter"
      "index": 0
    }
  ]
}

Completion API

The Completion API allows you to generate text completions based on a given prompt. This is useful for tasks like text generation, code completion, and more.

Request Format

POST /v1/completions
Content-Type: application/json

{
  "prompt": "Once upon a time",
  "temperature": 0.7,     // Controls randomness (0.0 to 1.0)
  "max_tokens": 1000,     // Maximum length of the completion
  "stop": ["\n", "END"], // Optional array of stop sequences
  "stream": false         // Set to true for streaming responses
}

Response Format

{
  "id": "cmpl-abc123",
  "object": "text_completion",
  "created": 1677649420,
  "model": "Best",
  "choices": [
    {
      "text": "in a magical kingdom...",
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop" // Possible values: "stop", "length", "content_filter"
    }
  ],
  "usage": {
    "prompt_tokens": 4,      // Number of tokens in the prompt
    "completion_tokens": 31,  // Number of tokens in the completion
    "total_tokens": 35       // Total tokens used
  }
}

Rate Limits

To ensure fair usage and maintain service quality, we implement rate limits on our API endpoints. These limits are based on your subscription plan.

PlanRequests per MinuteTokens per RequestMonthly Token Limit
Free604,000100,000
Pro3008,0001,000,000
EnterpriseCustom32,000Custom

* Rate limits are applied per API key. If you need higher limits, please contact our support team.