Skip to main content

Fastest OpenAI client — Rust core with Python bindings

Project description

openai-oxide for Python

PyPI PyPI downloads

Python bindings for openai-oxide — the fastest OpenAI client. Also available on crates.io (Rust) and npm (Node.js).

Rust core compiled to native Python extension via PyO3 + maturin.

Install

pip install openai-oxide
# or
uv pip install openai-oxide
# or
uv add openai-oxide

For local development (requires Rust toolchain):

cd openai-oxide-python
uv sync
uv run maturin develop --release

Usage

import asyncio, json
from openai_oxide import Client

async def main():
    client = Client()  # reads OPENAI_API_KEY env var

    # Simple
    r = await client.create("gpt-4o-mini", "Hello!")
    print(r["text"])

    # Streaming
    stream = await client.create_stream("gpt-4o-mini", "Explain quantum computing...", max_output_tokens=200)
    async for event in stream:
        print(event)

    # Structured output
    schema = json.dumps({
        "type": "object",
        "properties": {"answer": {"type": "integer"}},
        "required": ["answer"],
        "additionalProperties": False
    })
    r = await client.create_structured("gpt-4o-mini", "What is 7*8?", "math", schema)
    print(json.loads(r["text"])["answer"])  # 56

    # Function calling
    tools = json.dumps([{
        "name": "get_weather",
        "description": "Get weather",
        "parameters": {
            "type": "object",
            "properties": {"city": {"type": "string"}},
            "required": ["city"],
            "additionalProperties": False
        }
    }])
    r = await client.create_with_tools("gpt-4o-mini", "Weather in Tokyo?", tools)
    print(r["function_calls"])

asyncio.run(main())

Test

uv run python test_oxide.py

Benchmarks

Run uv run python examples/bench_python.py to compare against the official openai SDK.

See the main README for full benchmark results.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openai_oxide-0.11.2.tar.gz (21.6 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

openai_oxide-0.11.2-cp314-cp314-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

openai_oxide-0.11.2-cp312-cp312-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.12Windows x86-64

openai_oxide-0.11.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file openai_oxide-0.11.2.tar.gz.

File metadata

  • Download URL: openai_oxide-0.11.2.tar.gz
  • Upload date:
  • Size: 21.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for openai_oxide-0.11.2.tar.gz
Algorithm Hash digest
SHA256 b44f10c0a78cc5abc16dcff565e6bd33c146aab18666ac57ca220cd2a847aae5
MD5 f27137daf9a83c0b1d268f12558d0890
BLAKE2b-256 3240399cc348bc57cbcea3ce31a7ca527588c8a05323e069f96b3ecc08f5f9ef

See more details on using hashes here.

File details

Details for the file openai_oxide-0.11.2-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for openai_oxide-0.11.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c75bd7436c43df456edb26712d468daa4eb47e564777ffeb8933f98d119f78fe
MD5 aff774e1bd4319145b9c83356b974247
BLAKE2b-256 849ff7cdca107bd43c41dcc29fbc04dabccdd963bd5342ff5477c3f17cccd946

See more details on using hashes here.

File details

Details for the file openai_oxide-0.11.2-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for openai_oxide-0.11.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ea20da34f6ba56904b5ba2afd85de02e1268b33867cd6057dc7d4516ecb9bf0f
MD5 8913b0573aa1e56a99b3bfa232566b44
BLAKE2b-256 b2c0266be27073e85a62ecdba3b9b4cc9a086937a792954a0ebf6e2a9f869901

See more details on using hashes here.

File details

Details for the file openai_oxide-0.11.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for openai_oxide-0.11.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4a5be79c8aea60671e13de7387d2b12110f3737bdd6d8e2db88382a3d4e3b0c2
MD5 528c50a9c57b0522dd1878dda0cc6b68
BLAKE2b-256 6f33dafcb6497bc45c0bc27fef9bc01a08eba03ecdcce3f6580fe7ecc8725a75

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page