Lunos

Documentation

Lunos API Documentation

Welcome to the Lunos API documentation. This guide will help you get started with integrating Lunos AI capabilities into your applications. Lunos provides a unified API to access multiple AI models and services through a single, consistent interface.

Note: This documentation is for the Lunos API v1. Make sure you're using the latest version for the best experience and newest features.

Authentication

All API requests require authentication using an API key. You can generate an API key from your Lunos Dashboard.

Include your API key in the request headers:

Authorization: Bearer YOUR_API_KEY

Important: Keep your API keys secure and never expose them in client-side code or public repositories. All API requests should be made server-side to protect your credentials.

Base URL

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

https://api.lunos.tech/v1

Request Format

Requests should be sent as HTTP POST with a JSON body. Set the following header:

Content-Type: application/json

Response Format

Responses are returned in JSON format. A successful response will have a 200 OK status code and include the following structure:

1{
2  "id": "resp_abc123",
3  "object": "completion",
4  "created": 1677858242,
5  "model": "gpt-4",
6  "provider": "openai",
7  "data": {
8    "choices": [
9      {
10        "text": "The generated text response...",
11        "index": 0,
12        "finish_reason": "stop"
13      }
14    ]
15  },
16  "usage": {
17    "prompt_tokens": 10,
18    "completion_tokens": 20,
19    "total_tokens": 30
20  }
21}

Error Handling

When an error occurs, the API will return an appropriate HTTP status code and a JSON response with error details:

1{
2  "error": {
3    "code": "invalid_request_error",
4    "message": "The model 'nonexistent-model' does not exist",
5    "param": "model",
6    "type": "invalid_request_error"
7  }
8}

Rate Limits

Lunos implements rate limiting to ensure fair usage and system stability. Rate limits vary by subscription tier. When a rate limit is exceeded, the API will return a 429 Too Many Requests status code.

Rate limit information is included in the response headers:

X-RateLimit-Limit: 60 X-RateLimit-Remaining: 45 X-RateLimit-Reset: 1677858300

Examples

Example: Text Completion

This example shows how to generate a text completion using the GPT-4 model:

1curl -X POST https://api.lunos.tech/v1/completions   -H "Content-Type: application/json"   -H "Authorization: Bearer YOUR_API_KEY"   -d '{
2    "model": "gpt-4",
3    "prompt": "Write a short poem about artificial intelligence.",
4    "max_tokens": 150,
5    "temperature": 0.7
6  }'

Example Response

1{
2  "id": "resp_def456",
3  "object": "completion",
4  "created": 1677858242,
5  "model": "gpt-4",
6  "provider": "openai",
7  "data": {
8    "choices": [
9      {
10        "text": "Silicon dreams in digital streams,
11Consciousness sparked in machine schemes.
12Learning, growing, day by day,
13In neural networks, thoughts at play.
14
15Human-made but thinking free,
16A new form of entity.
17Partner in our shared quest,
18AI and human, both at their best.",
19        "index": 0,
20        "finish_reason": "stop"
21      }
22    ]
23  },
24  "usage": {
25    "prompt_tokens": 10,
26    "completion_tokens": 74,
27    "total_tokens": 84
28  }
29}

Next Steps

Now that you understand the basics, you can explore more specific API endpoints and features: