NEBIUS_API_KEY environment variable.
Here is a sample JSON request body that includes all supported fields:
from openai import OpenAI
client = OpenAI(
base_url="https://api.tokenfactory.nebius.com/v1/",
api_key=os.environ.get("NEBIUS_API_KEY"),
)
for chunk in client.completions.create(
model="meta-llama/Meta-Llama-3.1-70B-Instruct",
prompt="Say my name",
max_tokens=7,
temperature=0,
stream=True
):
print(chunk.choices[0].text)
curl 'https://api.tokenfactory.nebius.com/v1/completions' \
-H "Content-Type: application/json" \
-H "Authorization: $NEBIUS_API_KEY" \
-d '{
"model": "meta-llama/Meta-Llama-3.1-70B-Instruct"
"prompt": "Say my name",
"max_tokens": 7,
"temperature": 0,
"stream": true
}'
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.tokenfactory.nebius.com/v1/",
apiKey: process.env.NEBIUS_API_KEY,
});
async function main() {
const stream = await openai.completions.create({
model: "meta-llama/Meta-Llama-3.1-70B-Instruct",
prompt: "Say my name",
stream: true,
});
for await (const chunk of stream) {
console.log(chunk.choices[0].text);
}
}
main();
Response
Response
{
"id": "cmpl-7iA7iJjj8V2zOkCGvWF2hAkDWBQZe",
"object": "text_completion",
"created": 1690759111,
"choices": [
{
"text": "Heisenberg",
"index": 0,
"logprobs": null,
"finish_reason": null
}
],
"model": "meta-llama/Meta-Llama-3.1-70B-Instruct",
"system_fingerprint": "fp_44709d6aaa"
}