API Reference
Integrate Mollyra AI into your applications with our comprehensive RESTful API.
Authentication
All API requests require an API key. Include your API key in the Authorization header of every request.
curl https://api.mollyra.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"
# Python
import requests
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
Chat Completions
Create chat-based completions using our advanced language models. Supports streaming, system messages, and multi-turn conversations.
POST
/v1/chat/completions
Request Body
| Parameter | Type | Description |
|---|---|---|
| modelrequired | string | The model to use (gpt-4-turbo, claude-3-opus, mollyra-x) |
| messagesrequired | array | Array of message objects with role and content |
| temperatureoptional | number | Sampling temperature (0-2). Default: 0.7 |
| max_tokensoptional | integer | Maximum tokens to generate. Default: 2048 |
| streamoptional | boolean | Enable streaming responses. Default: false |
{
"model": "gpt-4-turbo",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
"temperature": 0.7,
"max_tokens": 1000
}
Response
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-4-turbo",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}],
"usage": {"prompt_tokens": 20, "completion_tokens": 10, "total_tokens": 30}
}
Image Generation
Generate images from text prompts using DALL-E 3 and our custom diffusion models.
POST
/v1/images/generations
Request Body
| Parameter | Type | Description |
|---|---|---|
| promptrequired | string | Text description of the desired image |
| modeloptional | string | Image model to use (dall-e-3, mollyra-diffusion). Default: dall-e-3 |
| noptional | integer | Number of images to generate (1-10). Default: 1 |
| sizeoptional | string | Image size (1024x1024, 1792x1024, 1024x1792) |
{
"prompt": "A futuristic cyberpunk city with neon lights, purple and cyan color scheme",
"model": "dall-e-3",
"n": 1,
"size": "1024x1024"
}
Embeddings
Generate vector embeddings for text, useful for semantic search, clustering, and similarity matching.
POST
/v1/embeddings
| Parameter | Type | Description |
|---|---|---|
| inputrequired | string or array | Text to embed |
| modeloptional | string | Embedding model (text-embedding-3-small, text-embedding-3-large) |
Available Models
| Model | Type | Context Window | Best For |
|---|---|---|---|
| gpt-4-turbo | Chat | 128K tokens | Complex reasoning, coding |
| gpt-3.5-turbo | Chat | 16K tokens | Fast responses, cost efficiency |
| claude-3-opus | Chat | 200K tokens | Long documents, analysis |
| claude-3-sonnet | Chat | 200K tokens | Balanced performance |
| mollyra-x | Chat | 32K tokens | Specialized tasks |
| dall-e-3 | Image | - | High-quality images |
Rate Limits
Rate limits vary by plan. Upgrade to Enterprise for higher limits.
| Plan | Requests/minute | Tokens/minute |
|---|---|---|
| Free | 20 | 10,000 |
| Pro | 500 | 500,000 |
| Enterprise | Custom | Custom |
Error Handling
Our API uses standard HTTP status codes. Error responses include a JSON body with details.
| Code | Meaning |
|---|---|
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Invalid API key |
| 403 | Forbidden - Insufficient permissions |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Server Error - Something went wrong on our end |
Official SDKs
Official SDKs are available for popular programming languages.
Python
pip install mollyra
Node.js
npm install mollyra-sdk
Go
go get github.com/mollyra/sdk
Ruby
gem install mollyra