API Documentation

Learn how to integrate OpenLLM API into your applications

Quick Start

Get started with OpenLLM API in minutes. Our API is fully compatible with OpenAI's interface.

1

1. Get Your API Key

Sign in and generate your API key from the settings page.

2

2. Install SDK

Install the OpenAI SDK or use our compatible endpoints.

bash
pip install openai
3

3. Make Your First Request

Start making requests with your preferred model.

Authentication

All API requests require authentication using your API key.

API Key Header

Include your API key in the Authorization header:

http
Authorization: Bearer YOUR_API_KEY

Keep your API keys secure and never expose them in client-side code.

Chat Completions

Generate conversational responses using various AI models.

Endpoint

http
POST https://api.openllm.dev/v1/chat/completions

Request Parameters

modelID of the model to use
messagesArray of message objects
temperatureSampling temperature (0-2)
max_tokensMaximum tokens to generate
streamEnable streaming responses

Example Request

typescript
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.openllm.dev/v1',
  apiKey: process.env.OPENLLM_API_KEY,
});

const response = await client.chat.completions.create({
  model: 'gpt-4',
  messages: [
    { role: 'user', content: 'Hello!' }
  ],
});

console.log(response.choices[0].message.content);

Python Example Request

python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.openllm.dev/v1",
    api_key="YOUR_API_KEY"
)

response = client.chat.completions.create(
    model="gpt-4",
    messages=[
        {"role": "user", "content": "Hello!"}
    ]
)

print(response.choices[0].message.content)

Available Models

Access hundreds of AI models through a single API.

List Models Endpoint

http
GET https://api.openllm.dev/v1/models
Flagship Models

Latest and most capable models from major providers

Coding Specialist

Optimized for code generation and technical tasks

Reasoning Models

Advanced reasoning and complex problem-solving

Multimodal

Support for images, audio, and video inputs

Streaming Responses

Stream responses in real-time for better user experience.

Benefits of streaming:

  • Reduced perceived latency
  • Real-time feedback
  • Better UX for long responses

Implementation Example

typescript
const stream = await client.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Tell me a story' }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content || '');
}

Error Handling

Understand and handle API errors effectively.

Common Error Codes

  • 401401 Unauthorized - Invalid API key
  • 429429 Too Many Requests - Rate limit exceeded
  • 500500 Internal Server Error - Service error
  • 503503 Service Unavailable - Temporary outage

Best Practices

  • Implement exponential backoff for retries
  • Handle rate limits gracefully
  • Log errors for debugging

Pricing & Billing

Transparent pricing based on actual usage.

ModelInput PriceOutput Price
GPT-4$5.00$15.00
GPT-3.5 Turbo$0.50$1.50
Claude 3 Opus$15.00$75.00

per 1M tokens

Pay-as-you-go pricing with no subscription required.

Track your usage and costs in real-time from the dashboard.

SDKs & Libraries

Official and community-maintained SDKs for popular languages.

Official SDKs

Python

Use the official OpenAI Python library

pip install openai
Node.js / TypeScript

Use the official OpenAI Node.js library

npm install openai

Popular Frameworks

LangChain: LangChain integration for building AI applications
Vercel AI SDK: Vercel AI SDK for React and Next.js applications

Rate Limits

API usage limits to ensure fair access and service stability.

TierRequestsTokens
Free100 req/day100K tokens/day
Pro10,000 req/day10M tokens/day

Rate limit information is included in response headers:

http
X-RateLimit-Limit: 10000
X-RateLimit-Remaining: 9999
X-RateLimit-Reset: 1640995200

Support & Resources

Community

Join our Discord community for help and discussions

Email Support

Contact our team at support@openllm.dev

Status Page

Check real-time API status and uptime

Changelog

Stay updated with latest features and improvements