Quick Start
To start using LyDian API, you first need an API key. You can create your API key from the Dashboard and start using it immediately.
Authentication
All API requests require an API key in the Authorization header. Send your API key as a Bearer token.
HTTP Header
Authorization: Bearer YOUR_API_KEY
Base URL
Base URL for all API endpoints. Always use HTTPS in production environment.
https://api.lydian.ai/v1
Chat Completion
Main endpoint for chatting with LyDian AI models. Streaming ve non-streaming modes. Use streaming for real-time responses.
/chat/completions
Ask questions to AI models with the chat completion endpoint, write code, create content, and more.
Request Parameters
| Parameter | Type | Description |
|---|---|---|
modelRequired |
string | Model ID (e.g.: "lydian-turbo", "lydian-pro") |
messagesRequired |
array | Array of chat messages (role, content) |
temperatureOptional |
number | 0 to 2 (default: 0.7) - Creativity level |
max_tokensOptional |
integer | Maximum number of tokens (default: 2000) |
streamOptional |
boolean | Streaming mode (default: false) |
Example Request
const response =
await
fetch('https://api.lydian.ai/v1/chat/completions', { method:
'POST', headers:
{ 'Authorization':
'Bearer sk-lydian-...',
'Content-Type':
'application/json'
},
body: JSON.stringify({ model:
'lydian-turbo',
messages: [ { role:
'user', content:
'Merhaba! AI ile neler yapabilirim?' } ],
temperature: 0.7,
max_tokens: 2000
}) });
const data =
await response.json(); console.log(data.choices[0].message.content);
import requests url =
"https://api.lydian.ai/v1/chat/completions"
headers = {
"Authorization":
"Bearer sk-lydian-...",
"Content-Type":
"application/json"
} data = {
"model":
"lydian-turbo",
"messages": [ {"role": "user",
"content":
"Merhaba! AI ile neler yapabilirim?"} ],
"temperature":
0.7,
"max_tokens":
2000 } response = requests.post(url, json=data, headers=headers)
print(response.json()["choices"][0]["message"]["content"])
curl https://api.lydian.ai/v1/chat/completions \ -H
"Authorization: Bearer sk-lydian-..." \ -H
"Content-Type: application/json" \ -d
'{ "model": "lydian-turbo", "messages": [ {"role": "user", "content":
"Merhaba! AI ile neler yapabilirim?"} ], "temperature": 0.7, "max_tokens":
2000 }'
Example Response
{ "id":
"chatcmpl-abc123",
"object":
"chat.completion",
"created":
1677858242,
"model":
"lydian-turbo",
"choices": [ {
"index": 0,
"message": { "role":
"assistant",
"content":
"Hello! You can do many things with AI..."
},
"finish_reason":
"stop"
} ],
"usage": {
"prompt_tokens":
12,
"completion_tokens":
145,
"total_tokens":
157 } }
Image Generation
Generate high-quality images from text descriptions. LyDian Image Engine ve and other image generation models.
/images/generate
Generate professional-quality images from text descriptions with the image generation endpoint. Different size and quality options available.
Request Parameters
| Parameter | Type | Description |
|---|---|---|
promptRequired |
string | Image description (max 1000 characters) |
sizeOptional |
string | "1024x1024", "1792x1024", "1024x1792" (default: "1024x1024") |
nOptional |
integer | Number of images to generate: 1-4 (default: 1) |
qualityOptional |
string | "standard" or "hd" (default: "standard") |
Example Request
curl https://api.lydian.ai/v1/images/generate \ -H
"Authorization: Bearer sk-lydian-..." \ -H
"Content-Type: application/json" \ -d
'{ "prompt": "Futuristic city with flying cars at sunset", "size": "1024x1024",
"n": 1, "quality": "hd" }'
Available Models
All AI models available on the LyDian platform. Each model comes with different capabilities and pricing.
/models
Lists all available AI models. Her modelin yetenekleri, context window size and pricing information.
Popular Models
Error Codes
API uses standard HTTP status codes. All error responses contain detailed error information in JSON format.
Status Codes
| Code | Status | Description |
|---|---|---|
200 |
OK | Request successful |
400 |
Bad Request | Request invalid or contains missing parameters |
401 |
Unauthorized | API key invalid or missing |
403 |
Forbidden | API key valid but unauthorized |
404 |
Not Found | Requested resource not found |
429 |
Rate Limit Exceeded | Too many requests sent |
500 |
Internal Server Error | Server error |
503 |
Service Unavailable | Service temporarily unavailable |
Error Response Format
{ "error": {
"message":
"Invalid API key provided",
"type":
"invalid_request_error",
"code":
"invalid_api_key" } }
Rate Limits
API rate limits are applied on a minute and hourly basis. When limits are exceeded, a 429 status code is returned. Each response contains headers with your rate limit information.
Default Limits
| Plan | Requests/Min | Requests/Hour | Tokens/Min |
|---|---|---|---|
| Free | 3 | 100 | 50,000 |
| Pro | 60 | 3,000 | 500,000 |
| Enterprise | Custom | Custom | Custom |
X-RateLimit-Limit, X-RateLimit-Remaining,
X-RateLimit-Reset