API Overview

Learn about the Tav-AI API structure, authentication, rate limits, and best practices for integration.

Base URL

All API requests should be made to the following base URL:

Base URL
https://api.tav-ai.com/v1

Authentication

The Tav-AI API uses API key authentication. Include your API key in the Authorization header of every request:

Authorization Header
Authorization: Bearer YOUR_API_KEY

🔐 Security Best Practices

  • Never expose your API key in client-side code
  • Use environment variables to store your API key
  • Rotate your API keys regularly
  • Use different API keys for different environments (dev, staging, prod)

Request Format

All requests should be made using HTTPS with JSON payloads. Include the appropriate Content-Type header:

Required Headers
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY

Response Format

All API responses are returned in JSON format. Successful responses will have a 200 status code, while errors will return appropriate HTTP status codes with error details.

Success Response

Successful Response Example
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "gpt-4o-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 9,
    "total_tokens": 21
  }
}

Error Response

Error Response Example
{
  "error": {
    "message": "Invalid API key provided",
    "type": "invalid_request_error",
    "code": "invalid_api_key"
  }
}

HTTP Status Codes

The API uses standard HTTP status codes to indicate the success or failure of requests:

200

OK

Request successful

400

Bad Request

Invalid request format or parameters

401

Unauthorized

Invalid or missing API key

429

Too Many Requests

Rate limit exceeded

500

Internal Server Error

Server-side error occurred

503

Service Unavailable

Service temporarily unavailable

Rate Limits

To ensure fair usage and maintain service quality, the Tav-AI API implements rate limiting:

Requests per Minute

60

Maximum requests per minute per API key

Tokens per Minute

150,000

Maximum tokens processed per minute

Concurrent Requests

10

Maximum simultaneous requests

📈 Rate Limit Headers

Each response includes headers with your current rate limit status:

  • X-RateLimit-Limit - Your rate limit ceiling
  • X-RateLimit-Remaining - Requests remaining in current window
  • X-RateLimit-Reset - Time when the rate limit resets

Available Endpoints

The Tav-AI API provides the following endpoints:

GET /v1/models

List available models and their capabilities

View Details →
POST /v1/chat/completions

Create chat completions with AI models

View Details →

OpenAI Compatibility

The Tav-AI API is designed to be compatible with OpenAI's API format, making it easy to migrate existing applications or use existing SDKs and tools.

🔄

Drop-in Replacement

Simply change the base URL in your existing OpenAI integration

📦

SDK Compatible

Works with official OpenAI SDKs for Python, Node.js, and more

🛠️

Tool Integration

Compatible with popular AI tools and frameworks

Best Practices

Follow these best practices for optimal API usage:

🚀 Performance

  • Implement request retry logic with exponential backoff
  • Cache responses when appropriate to reduce API calls
  • Use streaming for long responses when available

🔒 Security

  • Store API keys securely using environment variables
  • Implement proper error handling to avoid exposing sensitive data
  • Use HTTPS for all requests

💰 Cost Optimization

  • Choose the appropriate model for your use case
  • Set reasonable max_tokens limits
  • Monitor your usage through the dashboard