Skip to content

vidaiUK/vidaisdk

Repository files navigation

Vidai

Universal OpenAI-compatible Client with structured output guarantees and provider abstraction.

Home page | Documentation

Installation

pip install vidaisdk

Quick Start

import os
from vidai import Vidai
from pydantic import BaseModel

# Optional: Alias as OpenAI for drop-in compatibility if desired
# from vidai import Vidai as OpenAI

class User(BaseModel):
    name: str
    age: int

client = Vidai(
    api_key=os.environ.get("OPENAI_API_KEY"),
    # It sends requests to OpenAI by default,
    # but strictly validates/repairs responses locally
)
# If you want to use a custom base_url or proxy, you can do this:
# client = Vidai(
#     api_key="your-key",
#     base_url="https://your-proxy.com/v1"
# )

response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Create a user named John, age 25"}],
    response_format=User
)

user = response.choices[0].message.parsed
print(user.name)  # "John"
print(user.age)   # 25

Using with Vidai Server (Auto-Discovery)

Vidai acts as a smart facade when connected to a Vidai Server proxy. It automatically discovers available models and applies provider-specific optimizations (like Claude tool-use) without any client-side configuration changes.

  1. Set your environment:
export VIDAI_PROVIDER=vidai
export VIDAI_BASE_URL=http://localhost:8000/v1
export VIDAI_SERVER_API_KEY=sk-...
  1. Use the client as usual:
client = Vidai() # Automatically detects 'vidai' provider from env
# Automatically routes to Anthropic, DeepSeek, Google based on model name
response = client.chat.completions.create(model="claude-3-haiku", ...)

Features

  • Drop-in Compatibility: 100% compatible with OpenAI SDK API (Completions & Responses)
  • Responses API: Type-safe, object-based access normalized across all providers.
  • Structured Output Guarantees: Automatic JSON repair and validation
  • Performance Tracking: Monitor SDK overhead and repair times
  • Provider Agnostic: Works with any AI provider through your proxy
  • Developer Friendly: Clear error messages and debugging support

Full documentation is available at https://Vidai.uk/docs/sdk/python/.

See the GitHub Repository for the latest updates.


🤝 BETTER TOGETHER FOR ENTERPRISE

Pair with Vidai.Server

The SDKs work standalone with any OpenAI-compatible endpoint, but represent a complete, enterprise-grade stack when paired with Vidai.Server. This Rust-based Enterprise Gateway handles 6,000+ RPS on a single Intel core with <20ms p95 latency, meeting the most demanding production requirements.

SDK Handles Server Handles (Enterprise Gateway)
Structured Output 📈 Rate Limiting & Quotas
🛠️ Auto JSON Repair 💰 Cost Tracking & Budgets
Type Safety (Zod/Pydantic) 🔑 API Key Management

License

Apache-2.0

About

Python SDK for VidaiServer

Resources

License

Stars

4 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors