Integrate AI characters, conversations, and image generation into your applications
All API requests require authentication using an API key. Include your API key in the request headers using Bearer authentication:
1// API Key Header2{3 "Authorization": "Bearer your_api_key_here"4}You can find your API key in your account settings under the API section. Keep this key secret and don't expose it in client-side code.
API requests are rate-limited based on your plan:
| Plan | Limit |
|---|---|
| Free | 5 requests per minute |
| Pro | 100 requests per minute |
Rate limit information is included in response headers: X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset.
Use the Models API to retrieve available language models (LLMs) or stable diffusion models (SD).
1GET /api/v1/models?type=llm23// Response4[5 {6 "id": "model_abc123",7 "name": "GPT-4",8 "max_context": 8192,9 "cost_per_1k_tokens": 0.0610 },11 {12 "id": "model_def456",13 "name": "Claude 3 Opus",14 "max_context": 100000,15 "cost_per_1k_tokens": 0.1516 }17]| Name | Type | Description |
|---|---|---|
| type | string | The type of models to retrieve. RequiredAvailable values: |
No LLM models available.
No SD models available.
The Completions API lets you generate responses from a language model.
1POST /api/v1/completions23// Request4{5 "messages": [6 {7 "role": "system",8 "content": "You are a helpful assistant."9 },10 {11 "role": "user",12 "content": "Tell me about AI."13 }14 ],15 "llm_id": "model_abc123",16 "agent_id": "agent_xyz789" // [Optional] Agent to use for the completion17}1819// Response20{21 "id": "msg_789xyz",22 "content": "AI, or artificial intelligence, refers to systems or machines that mimic human intelligence...",23 "role": "agent",24 "created_at": "2023-09-01T12:00:00Z"25}| Name | Type | Description |
|---|---|---|
| messages | array | An array of message objects. Each message must have |
| llm_id | string | The ID of the language model to use. Required |
| agent_id | string | The ID of an agent to use for the completion. Optional |
Manage ongoing conversations with language models.
1GET /api/v1/conversations23// Response4[5 {6 "id": "conv_123abc",7 "title": "AI Discussion",8 "system_prompt": "You are a helpful assistant.",9 "llm_id": "model_abc123",10 "last_message_at": "2023-09-01T12:00:00Z",11 "agent_id": "agent_xyz789"12 }13]1POST /api/v1/conversations23// Request4{5 "title": "New Discussion",6 "system_prompt": "You are a helpful assistant.",7 "llm_id": "model_abc123",8 "agent_id": "agent_xyz789", // [Optional] Agent to associate with conversation9 "messages": [] // [Optional] Initial messages for the conversation10}1112// Response13{14 "id": "conv_123abc",15 "title": "New Discussion",16 "system_prompt": "You are a helpful assistant.",17 "llm_id": "model_abc123",18 "last_message_at": "2023-09-01T12:00:00Z",19 "agent_id": "agent_xyz789"20}1GET /api/v1/conversations/{id}23// Response4{5 "id": "conv_123abc",6 "title": "AI Discussion",7 "system_prompt": "You are a helpful assistant.",8 "llm_id": "model_abc123",9 "last_message_at": "2023-09-01T12:00:00Z",10 "agent_id": "agent_xyz789"11}Manage messages within a conversation.
1GET /api/v1/conversations/{conversation_id}/messages23// Response4[5 {6 "id": "msg_123abc",7 "content": "Hello, how can I help you today?",8 "role": "agent",9 "created_at": "2023-09-01T12:00:00Z"10 },11 {12 "id": "msg_456def",13 "content": "I'd like to learn about AI.",14 "role": "user",15 "created_at": "2023-09-01T12:01:00Z"16 }17]1POST /api/v1/conversations/{conversation_id}/messages23// Request4{5 "content": "Tell me about neural networks.",6 "llm_id": "model_abc123", // [Optional] LLM to use (defaults to conversation's LLM)7 "verbose": true // [Optional] Include thought process in response8}910// Response11{12 "id": "msg_789xyz",13 "content": "Neural networks are computational models inspired by the human brain...",14 "role": "agent",15 "created_at": "2023-09-01T12:05:00Z"16}Manage AI agents with customizable appearances and personalities.
1GET /api/v1/agents23// Response4[5 {6 "id": "agent_xyz789",7 "name": "Technical Advisor",8 "appearance_prompt": "Professional, wearing glasses",9 "personality_prompt": "Helpful and technically proficient",10 "description": "A technical expert who can help with coding questions"11 }12]1POST /api/v1/agents23// Request4{5 "name": "Financial Advisor",6 "appearance_prompt": "Professional, suit and tie",7 "personality_prompt": "Knowledgeable about finance, patient",8 "description": "An agent specialized in financial advice",9 "sd_model_id": "sd_model_456abc",10 "age": 3511}1213// Response14{15 "id": "agent_789abc",16 "name": "Financial Advisor",17 "appearance_prompt": "35 years old, Professional, suit and tie",18 "personality_prompt": "Knowledgeable about finance, patient",19 "description": "An agent specialized in financial advice",20 "avatar_url": "https://example.com/images/agent_789abc.png"21}| Name | Type | Description |
|---|---|---|
| name | string | Name of the agent. Required |
| appearance_prompt | string | Description of the agent's appearance for image generation. |
| personality_prompt | string | Description of the agent's personality. |
| description | string | General description of the agent's purpose. |
| sd_model_id | string | ID of the stable diffusion model to use for generating the agent's avatar. Required |
| age | number | Age of the agent (must be 18 or older). Optional |
sd_model_id is provided, the response will include an avatar_url field with the generated image.age parameter Optional is provided, it will be prepended to the appearance prompt.1GET /api/v1/agents/{id}23// Response4{5 "id": "agent_xyz789",6 "name": "Technical Advisor",7 "appearance_prompt": "Professional, wearing glasses",8 "personality_prompt": "Helpful and technically proficient",9 "description": "A technical expert who can help with coding questions"10}Generate and retrieve AI-created images.
1GET /api/v1/images?page=1&page_size=1023// Response4{5 "data": [6 {7 "id": "img_123abc",8 "prompt": "A futuristic city with flying cars",9 "url": "https://example.com/images/img_123abc.png",10 "created_at": "2023-09-01T12:00:00Z"11 }12 ],13 "pagination": {14 "total_items": 25,15 "current_page": 1,16 "page_size": 10,17 "total_pages": 3,18 "next_page": 2,19 "prev_page": null20 }21}1POST /api/v1/images23// Request4{5 "prompt": "A serene beach at sunset with palm trees",6 "sd_model_id": "sd_model_456abc",7 "conversation_id": "conv_123abc" // [Optional] Link image to this conversation8}910// Response11{12 "id": "img_789xyz",13 "prompt": "A serene beach at sunset with palm trees",14 "url": "https://example.com/images/img_789xyz.png",15 "created_at": "2023-09-01T12:10:00Z"16}| Name | Type | Description |
|---|---|---|
| prompt | string | Description of the image to generate. Required |
| sd_model_id | string | The ID of the stable diffusion model to use. Required |
| conversation_id | string | Link the image to a conversation. Optional |
conversation_id is provided, the system will automatically insert the generated image into the conversation thread as a message with no text content, just an image.The API uses standard HTTP status codes to indicate success or failure of requests:
1// Success (200, 201)2{3 "id": "resource_id",4 "name": "Resource Name",5 // Other resource properties6}78// Client Error (400, 401, 402, 404)9{10 "error": "Detailed error message explaining what went wrong"11}1213// Server Error (500)14{15 "error": "Internal error"16}| Code | Description |
|---|---|
| 200 OK | Request succeeded |
| 201 Created | Resource successfully created |
| 400 Bad Request | Invalid parameters or request format |
| 402 Payment Required | Insufficient account balance |
| 404 Not Found | Resource not found |
| 500 Internal Server Error | Server-side error |