ainative-openai
Drop-in replacement for the OpenAI Python SDK that routes to AINative's free API — Llama, Qwen, DeepSeek, and Kimi models with zero configuration.
Install
pip install ainative-openai
Quick Start
Replace from openai import OpenAI with from ainative_openai import OpenAI. That's it.
from ainative_openai import OpenAI
client = OpenAI() # auto-provisions a free API key
response = client.chat.completions.create(
model="meta-llama/Llama-3.3-70B-Instruct",
messages=[{"role": "user", "content": "Explain quantum computing in 3 sentences."}],
)
print(response.choices[0].message.content)
First run auto-provisions a free API key (72h expiry) and saves it to ~/.ainative/config.json. Follow the printed claim URL to get a permanent key.
Async
import asyncio
from ainative_openai import AsyncOpenAI
async def main():
client = AsyncOpenAI()
response = await client.chat.completions.create(
model="qwen3-coder-flash",
messages=[{"role": "user", "content": "Write a Python fibonacci generator"}],
)
print(response.choices[0].message.content)
asyncio.run(main())
Streaming
from ainative_openai import OpenAI
client = OpenAI()
stream = client.chat.completions.create(
model="deepseek-4-flash",
messages=[{"role": "user", "content": "Write a haiku about code"}],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
Tool Calling
from ainative_openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="meta-llama/Llama-3.3-70B-Instruct",
messages=[{"role": "user", "content": "What's the weather in Austin?"}],
tools=[{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}],
)
Available Models
| Model | ID |
|---|---|
| Llama 3.3 70B | meta-llama/Llama-3.3-70B-Instruct |
| Llama 4 Scout | meta-llama/Llama-4-Scout-17B-16E-Instruct |
| Qwen3 Coder Flash | qwen3-coder-flash |
| DeepSeek 4 Flash | deepseek-4-flash |
| Kimi K2 | kimi-k2 |
All models are free on AINative's API.
Authentication Priority
The client resolves API keys in this order:
api_keyargumentAINATIVE_API_KEYenvironment variableOPENAI_API_KEYenvironment variable- Saved key in
~/.ainative/config.json - Auto-provision via instant-db (free, 72h expiry)
Configuration
# Explicit key
client = OpenAI(api_key="your-ainative-key")
# Custom base URL (self-hosted)
client = OpenAI(api_key="key", base_url="http://localhost:8000/v1")
# Environment variables
# AINATIVE_API_KEY=your-key
# AINATIVE_BASE_URL=https://custom.endpoint/v1
Migrating from OpenAI
- from openai import OpenAI
+ from ainative_openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
- model="gpt-4",
+ model="meta-llama/Llama-3.3-70B-Instruct",
messages=[{"role": "user", "content": "Hello!"}],
)
Every feature of the official openai SDK works — this is a thin subclass that only changes the defaults.
License
MIT
Metadata
Release files for ainative-openai 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ainative_openai-0.1.0.tar.gz | 7.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ainative_openai-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.8 kB
Release files / ainative_openai-0.1.0.tar.gz
| Download URL | ainative_openai-0.1.0.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6346e9025f62d98b325581c8c8466166b8583aa71a46ad535f8916833d1dac52
|
|
BLAKE2b-256 checksum How to use checksums |
1b39dbabb16fd7886268f127ce95946fb1dd64e1fecb9ab642ed25db7ee8d507
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / ainative_openai-0.1.0-py3-none-any.whl
| Download URL | ainative_openai-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0184265b9a60a595ef890c6adb54f20bb17c08122217d51c4b2c4a5af9a8d95a
|
|
BLAKE2b-256 checksum How to use checksums |
ab04719ba0c84e5524ee75ef38ec3d881e7adb594d873f352e9f3118bdd0b0b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|