This guide will help you get up and running with Lunos AI Platform in just a few minutes. Follow these simple steps to start integrating AI capabilities into your applications.
Note: This guide assumes you have already created a Lunos account. Checking authentication status...
To use the Lunos API, you'll need an API key. You can create one from your dashboard:
Important: Your API key is sensitive information. Never share it publicly or commit it to version control.
The easiest way to use the Lunos API in JavaScript/TypeScript is with our official client library: @lunos/client.
npm install @lunos/client
pip install openai
Note: @lunos/client is the official and recommended package for JavaScript/TypeScript. You can also use the OpenAI library for compatibility, or use cURL/Python for other languages.
Initialize the Lunos client with your API key:
1import { LunosClient } from '@lunos/client';
2
3const client = new LunosClient({
4 apiKey: 'your_api_key_here',
5 baseURL: 'https://api.lunos.tech/v1',
6 appId: 'your_app_id_here', // optional
7});
Note: The appId
is optional and can be used to track usage of your application.
1from openai import OpenAI
2
3client = OpenAI(
4 api_key="your_api_key_here",
5 base_url="https://api.lunos.tech/v1",
6 default_headers={
7 "X-App-ID": "your_app_id_here" // optional
8 }
9)
Note: The X-App-ID
header is optional and can be used to track usage of your application.
Let's make a simple API call to generate a text completion:
1import { LunosClient } from '@lunos/client';
2
3const client = new LunosClient({
4 apiKey: 'your_api_key_here',
5 baseURL: 'https://api.lunos.tech/v1',
6 appId: 'your_app_id_here', // optional
7});
8
9async function generateCompletion() {
10 try {
11 const response = await client.chat.createCompletion({
12 model: 'openai/gpt-4o',
13 messages: [
14 { role: 'user', content: 'Write a short poem about artificial intelligence.' }
15 ],
16 max_tokens: 150,
17 temperature: 0.7,
18 });
19 console.log(response.choices[0].message.content);
20 } catch (error) {
21 console.error('Error:', error);
22 }
23}
24
25generateCompletion();
1def generate_completion():
2 try:
3 response = client.completions.create(
4 model="openai/gpt-4o",
5 prompt="Write a short poem about artificial intelligence.",
6 max_tokens=150,
7 temperature=0.7
8 )
9 print(response.choices[0].message.content)
10 except Exception as e:
11 print(f"Error: {e}")
12
13generate_completion()
Congratulations! You've made your first API call to Lunos. Now you can explore more features and capabilities:
If you encounter any issues or have questions, our support team is here to help.
No headings found on this page.