NovaKitv1.0

OpenAI SDK Compatibility

Use the OpenAI SDK with NovaKit as a drop-in replacement

OpenAI SDK Compatibility

NovaKit's chat completions endpoint is fully compatible with the OpenAI SDK, making it easy to migrate existing applications or use familiar tooling.

The OpenAI SDK works with NovaKit's chat completions endpoint. For other features (images, video, audio, music), use our REST API directly.

Quick Start

from openai import OpenAI

client = OpenAI(
    api_key="sk_your_novakit_api_key",
    base_url="https://www.novakit.ai/api/v1"
)

response = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello!"}]
)

print(response.choices[0].message.content)
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "sk_your_novakit_api_key",
  baseURL: "https://www.novakit.ai/api/v1",
});

const response = await client.chat.completions.create({
  model: "openai/gpt-4o-mini",
  messages: [{ role: "user", content: "Hello!" }],
});

console.log(response.choices[0].message.content);
curl https://www.novakit.ai/api/v1/chat/completions \
  -H "Authorization: Bearer sk_your_novakit_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Migrating from OpenAI

If you're currently using the OpenAI API, migration requires only two changes:

Before (OpenAI)

from openai import OpenAI

client = OpenAI(
    api_key="sk-your-openai-key"  # OpenAI key
)

response = client.chat.completions.create(
    model="gpt-4o-mini",  # OpenAI model name
    messages=[{"role": "user", "content": "Hello!"}]
)

After (NovaKit)

from openai import OpenAI

client = OpenAI(
    api_key="sk_your_novakit_key",  # 1. Change to NovaKit key
    base_url="https://www.novakit.ai/api/v1"  # 2. Add base URL
)

response = client.chat.completions.create(
    model="openai/gpt-4o-mini",  # 3. Prefix with provider
    messages=[{"role": "user", "content": "Hello!"}]
)

Supported Features

FeatureSupportedNotes
Chat completionsYesFull support
StreamingYesSSE streaming
System messagesYesFull support
Multi-turn conversationsYesFull support
Temperature/max_tokensYesStandard parameters
Vision (image analysis)YesVia images array
Function callingPartialModel-dependent

Model Name Mapping

NovaKit uses provider-prefixed model names:

OpenAI ModelNovaKit Model
gpt-4oopenai/gpt-4o
gpt-4o-miniopenai/gpt-4o-mini
gpt-4-turboopenai/gpt-4-turbo
gpt-3.5-turboopenai/gpt-3.5-turbo

You can also use models from other providers:

ProviderExample Model
Anthropicanthropic/claude-3.5-sonnet
Googlegoogle/gemini-pro
Metameta-llama/llama-3-70b

Streaming Example

from openai import OpenAI

client = OpenAI(
    api_key="sk_your_novakit_key",
    base_url="https://www.novakit.ai/api/v1"
)

stream = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    messages=[{"role": "user", "content": "Write a haiku about coding"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

Environment Variables

For cleaner code, use environment variables:

export OPENAI_API_KEY="sk_your_novakit_key"
export OPENAI_BASE_URL="https://www.novakit.ai/api/v1"

Then your code doesn't need explicit configuration:

from openai import OpenAI

client = OpenAI()  # Uses environment variables

response = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello!"}]
)

Limitations

The following OpenAI SDK features are not supported through NovaKit:

  • client.images.generate() - Use our REST API for images
  • client.audio.speech.create() - Use our REST API for TTS
  • client.audio.transcriptions.create() - Use our REST API for STT
  • Assistants API
  • Embeddings API
  • Fine-tuning API

For features not covered by OpenAI SDK compatibility, use our REST API directly.

On this page