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.1.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.1-cp314-cp314-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

openai_oxide-0.11.1-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.1.tar.gz.

File metadata

  • Download URL: openai_oxide-0.11.1.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.1.tar.gz
Algorithm Hash digest
SHA256 8a980fa96274c1b47ce7ad40e4112aeae6f0c515b2445b71a8526e30a60d699a
MD5 2285b1655ecd2ee5b090c0173b8ec67d
BLAKE2b-256 f1794e87d4afae3dfae2226a7f0c2e99bfc38c9eabbcc0bea140093c3069002c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openai_oxide-0.11.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 35fed03b8433284349d3acefca233612231886d1521028057e45d010875b062e
MD5 f96848c1b8a59eba0e7bd3a1d0768603
BLAKE2b-256 5ba145b017bfe5d10eec5b50687315358991c20b065782911614ec5951944011

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openai_oxide-0.11.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f7d2e41194ffcb37f64be0b7170392f2860dc928d99fd7cae122edd1a2e1fd30
MD5 2b5e7908f14299d9269d2c03c172ebb7
BLAKE2b-256 a3fd90fcbda832d484b54b79d60114f6c7deb32f95499b1591a0d247ba3c178f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openai_oxide-0.11.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 52bf756c67d8ef88b4b8ebcf6384f37887bd471b6986e79754aa4eed3ccd0af2
MD5 6cacd77934fe28f58358b902d096944d
BLAKE2b-256 94faddfb7dcb1e5ca2b1915ee532b4d3431e18cab1fda45881d0eec19bbc51d0

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