Skip to content

Use the OpenAI SDK with the i14 API

Because the i14 API is fully OpenAI-compatible, you can use the official OpenAI SDK in Python or Node.js by changing only the base_url (Python) or baseURL (Node.js) and your API key. Everything else - your prompts, model parameters, and response handling - stays exactly the same.

Install the OpenAI Python SDK if you have not already:

pip install openai
import openai
client = openai.OpenAI(
base_url="https://api.i14.ai/v1",
api_key="YOUR_I14_API_KEY",
)
response = client.chat.completions.create(
model="i14-sugarglider-nemotron3-super-120B-v1",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain the difference between a process and a thread."},
],
max_tokens=8192,
stream=True,
)
for chunk in response:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
import openai
client = openai.OpenAI(
base_url="https://api.i14.ai/v1",
api_key="YOUR_I14_API_KEY",
)
response = client.chat.completions.create(
model="i14-sugarglider-nemotron3-super-120B-v1",
messages=[
{"role": "system", "content": "You are an expert software engineer."},
{"role": "user", "content": "Write a Python function that reverses a string."},
],
max_tokens=8192,
stream=True,
)
for chunk in response:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")

Install the OpenAI Node.js SDK if you have not already:

npm install openai
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.i14.ai/v1",
apiKey: "YOUR_I14_API_KEY",
});
const response = await client.chat.completions.create({
model: "i14-sugarglider-nemotron3-super-120B-v1",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Explain the difference between a process and a thread." },
],
max_tokens: 8192,
stream: true,
});
for await (const chunk of response) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.i14.ai/v1",
apiKey: "YOUR_I14_API_KEY",
});
const response = await client.chat.completions.create({
model: "i14-sugarglider-nemotron3-super-120B-v1",
messages: [
{ role: "system", content: "You are an expert software engineer." },
{ role: "user", content: "Write a TypeScript function that reverses a string." },
],
max_tokens: 8192,
stream: true,
});
for await (const chunk of response) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

Hardcoding your API key is fine for quick tests, but you should store it in an environment variable for any code you share or deploy.

Set the variable in your shell:

bash or zsh
export I14_API_KEY="your-api-key-here"

Then read it in your code:

import os
import openai
client = openai.OpenAI(
base_url="https://api.i14.ai/v1",
api_key=os.environ["I14_API_KEY"],
)