Pre-configured instructor client for structured output extraction via AINative's free LLM API
Project description
instructor-ainative
Pre-configured instructor client for structured output extraction using AINative's free LLM API.
Zero setup. Works with Llama 3.3 70B, Qwen3, DeepSeek 4, and Kimi K2 — all free.
Install
pip install instructor-ainative
Quick Start
from instructor_ainative import get_client
from pydantic import BaseModel
class User(BaseModel):
name: str
age: int
client = get_client() # Auto-provisions free API key
user = client.chat.completions.create(
model="meta-llama/Llama-3.3-70B-Instruct",
response_model=User,
messages=[{"role": "user", "content": "Extract: John is 30"}],
)
print(user) # User(name='John', age=30)
How It Works
instructor-ainative wraps instructor with a pre-configured OpenAI client pointing at AINative's free, OpenAI-compatible API. You get structured Pydantic output extraction from open-source models without any API key setup.
On first use, the package auto-provisions a free API key (72-hour TTL). Claim your account at ainative.studio/signup for permanent access.
Available Models
Use aliases or full model IDs:
from instructor_ainative import get_model, MODELS
# Aliases
get_model("llama") # meta-llama/Llama-3.3-70B-Instruct
get_model("qwen") # qwen3-coder-flash
get_model("deepseek") # deepseek-4-flash
get_model("kimi") # kimi-k2
Async Support
import asyncio
from instructor_ainative import get_async_client
from pydantic import BaseModel
class User(BaseModel):
name: str
age: int
async def main():
client = get_async_client()
user = await client.chat.completions.create(
model="meta-llama/Llama-3.3-70B-Instruct",
response_model=User,
messages=[{"role": "user", "content": "Extract: John is 30"}],
)
print(user)
asyncio.run(main())
Configuration
API Key Resolution Order
- Explicit
api_keyparameter AINATIVE_API_KEYenvironment variableZERODB_API_KEYenvironment variable~/.zerodb/credentials.json(shared with ZeroDB ecosystem)- Auto-provision (free, 72-hour TTL)
Bring Your Own Key
export AINATIVE_API_KEY=your-key-here
# Or pass directly
client = get_client(api_key="your-key-here")
Custom Base URL
client = get_client(base_url="https://your-proxy.example.com/v1")
Instructor Mode
import instructor
client = get_client(mode=instructor.Mode.TOOLS) # Default is JSON mode
Complex Extraction
from instructor_ainative import get_client
from pydantic import BaseModel, Field
from typing import List
class Address(BaseModel):
street: str
city: str
state: str
zip_code: str = Field(description="5-digit ZIP code")
class Contact(BaseModel):
name: str
email: str
phone: str
addresses: List[Address]
client = get_client()
contact = client.chat.completions.create(
model="meta-llama/Llama-3.3-70B-Instruct",
response_model=Contact,
messages=[{
"role": "user",
"content": """
Extract contact info: Jane Smith, jane@example.com, 555-0123.
Lives at 123 Main St, Austin TX 78701 and
456 Oak Ave, Denver CO 80202.
"""
}],
)
Why instructor-ainative?
| Feature | instructor + OpenAI | instructor-ainative |
|---|---|---|
| Setup | Get API key, set env var | pip install and go |
| Cost | Pay per token | Free |
| Models | GPT-4o, etc. | Llama 70B, Qwen, DeepSeek |
| Structured output | Yes | Yes |
| Auto-provisioning | No | Yes |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file instructor_ainative-0.1.0.tar.gz.
File metadata
- Download URL: instructor_ainative-0.1.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2aeee2611e5b97064c28e5906176b2965ef1616dc8ef1b46eafc912b35e9a037
|
|
| MD5 |
f8250cf04b19a8b33cd5719154e5067d
|
|
| BLAKE2b-256 |
57ab49444481962ad11adb26713654e764b1cd60bca3d94c3b686c9c13106ddc
|
File details
Details for the file instructor_ainative-0.1.0-py3-none-any.whl.
File metadata
- Download URL: instructor_ainative-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
495e4e7bda7f7b011ed559ee032cde4125b5cf3d899c364e9f5869991e42ffa7
|
|
| MD5 |
f7a2ee15a7011812f2fdf5e1d477fb5f
|
|
| BLAKE2b-256 |
0290e615bac805e1fa1d1e422048911609aaed85b3861694eee6eba98ae528c8
|