Skip to main content

First API Call

Now, let's use your key to interact with an AI model. Our API is compatible with the OpenAI SDK, making integration incredibly simple.

Installation

First, make sure you have the necessary library for your programming language.

pip install openai 

Code Example

Use the following code snippet to send a request. Remember to replace YOUR_API_KEY with the key you just created.

from openai import OpenAI

# Initialize the client

client = OpenAI(
base_url='https://api.naga.ac/v1',
api_key='YOUR_API_KEY' # 🐲 Your NagaAI API key
)

# Create the chat completion request

response = client.chat.completions.create(
model='gpt-4o-mini',
messages=[{'role': 'user', 'content': "What is the capital of France?"}]
)

# Print the response

print(response.choices[0].message.content)

If everything is correct, you should receive a response like: The capital of France is Paris.

For More Examples

Looking for more? Check out our Code Examples for more advanced use cases.