Here are examples of Python, cURL and JavaScript SDK command that makes an API request from your terminal:
import os
from openai import OpenAI
client = OpenAI(
base_url = "https://api.tokenfactory.nebius.com/v1/" ,
api_key = os.environ.get( "NEBIUS_API_KEY" ),
)
completion = client.chat.completions.create(
model = "meta-llama/Meta-Llama-3.1-70B-Instruct" ,
messages = [
{
"role" : "user" ,
"content" : """Hello!"""
}
],
temperature = 0.6
)
print (completion.to_json())
curl 'https://api.tokenfactory.nebius.com/v1/chat/completions' \
-X 'POST' \
-H 'Content-Type: application/json' \
-H 'Accept: */*' \
-H "Authorization: Bearer $NEBIUS_API_KEY " \
--data-binary '{"temperature":0.6,"model":"meta-llama/Meta-Llama-3.1-70B-Instruct","messages":[{"role":"user","content":"Hello!"}]}'
const OpenAI = require ( "openai" );
const client = new OpenAI ({
baseURL: "https://api.tokenfactory.nebius.com/v1/" ,
apiKey: process . env . NEBIUS_API_KEY ,
});
client . chat . completions . create ({
"temperature" : 0.6 ,
"model" : "meta-llama/Meta-Llama-3.1-70B-Instruct" ,
"messages" : [
{
"role" : "user" ,
"content" : "Hello!"
}
]
})
. then (( completion ) => console . log ( completion ));
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello! It's nice to meet you. Is there something I can help you with, or would you like to chat?",
"role": "assistant"
}
}
],
"created": 1717516032,
"model": "meta-llama/Meta-Llama-3-70B-Instruct-cheap",
"object": "chat.completion",
"usage": {
"completion_tokens": 26,
"prompt_tokens": 13,
"total_tokens": 39
}
}
For more examples, see Examples of using the Nebius Token Factory API .
Authentication
To authenticate, include your API key (e.g., ABC123...) in the Authorization header, as shown below:
Authorization: Bearer ABC123...
Keep your keys private; do not share or expose them in client-side code. If a key is compromised, Nebius Token Factory can automatically revoke it
To get an API key:
In Nebius Token Factory, go to the API keys section.
Click Create API key .
Enter the key name and then click Create .
Save the displayed API key. You cannot open it later in Nebius Token Factory.