Lunos

Documentation

API Reference

This is the reference documentation for the Lunos API. The API provides programmatic access to Lunos's AI capabilities, allowing you to integrate multiple AI models into your applications through a single, unified interface.

Important: Make sure to keep your API keys secure and never expose them in client-side code. All API requests should be made server-side to protect your credentials.

Request Headers

X-App-ID Header

The X-App-ID header allows you to identify the application making the request for analytics and usage tracking.

HeaderTypeRequiredDescription
X-App-IDstringNoIdentifies the application making the request. Defaults to "Unknown" if not provided.

Example Request Headers

Example Headers
1Authorization: Bearer YOUR_API_KEY
2Content-Type: application/json
3X-App-ID: my-application-v1.0

Analytics & Usage Tracking: The X-App-ID header allows you to track usage and analytics per application. The app ID is stored in the query history table and can be used for:

  • Usage analytics per application
  • Billing and cost tracking per app
  • Performance monitoring per application
  • Rate limiting per application (if implemented)

Base URL

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

https://api.lunos.tech/v1

Note: The /public/models endpoint is an exception and uses the base URL https://api.lunos.tech without the /v1 prefix, as it's a publicly accessible endpoint that doesn't require authentication.

Available Endpoints

Current Status: At this time, only the /completions endpoint is available for AI access. Other endpoints are planned for future releases.

EndpointMethodDescription
/public/modelsGETList all available AI models (public endpoint)
/completionsPOSTGenerate text completions
/chat/completionsPOSTGenerate chat completions
/embeddingsPOSTGenerate text embeddings
/images/generationsPOSTGenerate images from text prompts
/audio/transcriptionsPOSTTranscribe audio to text

Models Endpoint

The models endpoint allows you to list and get information about the available models.

Public Access: This endpoint is publicly accessible and doesn't require authentication or API keys. It uses a different URL structure than other API endpoints.

List Models

GET https://api.lunos.tech/public/models

Returns a list of all models available through the Lunos API. Unlike other endpoints, this uses the full URL https://api.lunos.tech/public/models and doesn't require the /v1 prefix or authentication headers.

Example Request

Example Request
1curl https://api.lunos.tech/public/models

Example Response

Example Response
1{
2  "status": "success",
3  "data": {
4    "models": [
5      {
6        "id": "gpt-4",
7        "provider": "openai",
8        "created": 1677610602,
9        "object": "model",
10        "owned_by": "openai",
11        "capabilities": ["text-completion", "chat-completion"],
12        "pricing": {
13          "input": 0.00003,
14          "output": 0.00006,
15          "unit": "token",
16          "currency": "USD"
17        }
18      },
19      {
20        "id": "claude-3-opus",
21        "provider": "anthropic",
22        "created": 1678410602,
23        "object": "model",
24        "owned_by": "anthropic",
25        "capabilities": ["chat-completion"],
26        "pricing": {
27          "input": 0.00003,
28          "output": 0.00015,
29          "unit": "token",
30          "currency": "USD"
31        }
32      },
33      // Additional models...
34    ]
35  },
36  "meta": {
37    "processing_time": 0.023
38  }
39}

Completions Endpoint

The completions endpoint allows you to generate text completions using various AI models.

POST /completions

Request Parameters

ParameterTypeRequiredDescription
modelstringYesID of the model to use
promptstringYesThe prompt to generate completions for
max_tokensintegerNoMaximum number of tokens to generate (default: 16)
temperaturenumberNoSampling temperature (0-2, default: 1)
top_pnumberNoNucleus sampling parameter (0-1, default: 1)

Client Library Examples

Here are examples of how to use the X-App-ID header with different client libraries:

JavaScript/TypeScript

JavaScript Example
1const response = await lunos.chat.completions.create({
2  model: "openai/gpt-4",
3  messages: [{ role: "user", content: "Hello" }],
4  appId: "my-web-app"
5});

Python

Python Example
1response = lunos.chat.completions.create(
2    model="openai/gpt-4",
3    messages=[{"role": "user", "content": "Hello"}],
4    app_id="my-python-app"
5)

cURL

cURL Example
1curl -X POST "https://api.lunos.tech/v1/chat/completions" \
2  -H "Authorization: Bearer YOUR_API_KEY" \
3  -H "Content-Type: application/json" \
4  -H "X-App-ID: my-curl-app" \
5  -d '{
6    "model": "openai/gpt-4",
7    "messages": [{"role": "user", "content": "Hello"}]
8  }'

Migration Guide

For Existing Users: The X-App-ID header is optional and backward compatible.

  • Existing code will continue to work without changes
  • To start tracking app usage, simply add the X-App-ID header to your requests
  • Recommended to add app IDs to all new implementations for better analytics

For more detailed information about specific endpoints, please refer to the corresponding documentation pages: