Skip to main content

AI Power Grid — Python SDK

Open-model, OpenAI-compatible inference across community-operated GPUs.

Release status: grid-sdk is published on PyPI. Use a current release so the OpenAI-compatible client and native Grid media helpers stay in sync.

The Grid API speaks the OpenAI protocol, so this SDK is a thin layer over the official openai package: it points at the Grid, reads your key from the environment, and adds Grid-specific conveniences. Everything you know from the OpenAI SDK works unchanged.

Install

pip install grid-sdk

Quick start

Sign in at the Grid developer console, create an API key, then set it as AIPG_API_KEY:

from grid_sdk import Grid

client = Grid()  # reads AIPG_API_KEY from the environment

stream = client.chat.completions.create(
    model="gpt-oss-120b",
    messages=[{"role": "user", "content": "Explain AI Power Grid in one line."}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="", flush=True)

See what's online

The Grid's available models change as workers connect and disconnect. Don't hardcode a model blindly — ask which ones are servable right now:

client = Grid()
print(client.online_models())
# ['gpt-oss-120b', 'qwen3-27b', ...]

An empty list means no workers are connected — requests will 503 until one is.

Credits

credits = client.grid.credits()
print(credits["total_spendable_usd"])

This is Core's canonical promotional, daily-free, and purchased account view. The SDK does not maintain a local free-use counter.

Async

import asyncio
from grid_sdk import AsyncGrid

async def main():
    client = AsyncGrid()
    resp = await client.chat.completions.create(
        model="gpt-oss-120b",
        messages=[{"role": "user", "content": "Hi"}],
    )
    print(resp.choices[0].message.content)

asyncio.run(main())

Video, img2img, ControlNet, LoRAs — the full Grid

The OpenAI-compatible surface covers text and basic txt2img. For the full media parameter surface, use client.grid, which calls the synchronous /v1 image and video endpoints:

client = Grid()

# Video:
result = client.grid.video(
    prompt="a timelapse of a city at night",
    model="LTX-2.3",
    width=768, height=512, seconds=4, fps=24,
)

# img2img / ControlNet / LoRAs — anything the workers support:
result = client.grid.image(
    prompt="make it watercolor",
    models=["FLUX.2 Klein 4B FP8"],
    source_image="<base64>",
    loras=[{"name": "watercolor", "model": 1.0}],
)

# Or full control with a raw payload:
result = client.grid.generate({"prompt": "...", "models": [...], "params": {...}})

client.grid waits for the synchronous Grid response and returns the finished OpenAI-shaped result. Use timeout for long media jobs; there is no SDK submit/poll mode on this /v1 client.

It's just OpenAI underneath

Grid subclasses openai.OpenAI, so anything the OpenAI SDK does — images, tool calling, structured output, the full .chat/.images/.models surface — works here too. You can also point existing OpenAI code at the Grid by setting base_url="https://api.aipowergrid.io/v1" if you'd rather not switch packages.

Config

Grid(api_key=...) Explicit key (overrides env)
AIPG_API_KEY Env var read when no key is passed
Grid(base_url=...) Override the endpoint (default https://api.aipowergrid.io/v1)

License

MIT

Metadata

Release files for grid-sdk 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grid-sdk 0.1.2
File Size Uploaded Provenance Actions
grid_sdk-0.1.2.tar.gz 10.2 kB With provenance Details for grid_sdk-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for grid-sdk 0.1.2
File Interpreter ABI Platform Actions
grid_sdk-0.1.2-py3-none-any.whl Python 3 none any Details for grid_sdk-0.1.2-py3-none-any.whl

Total release size: 18.5 kB

Release files / grid_sdk-0.1.2.tar.gz

Download URL grid_sdk-0.1.2.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
88b310db8d3a72aff77fb896b19e76a98b1fda0a5606557769ea07f92a130c0b
BLAKE2b-256 checksum
How to use checksums
ff5f42b4994a8e518c62aa0dd7abfb7b18b93e2841a22aeb09c5a726f396d461
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / grid_sdk-0.1.2-py3-none-any.whl

Download URL grid_sdk-0.1.2-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd61de83ae936847e9b49c80df085ba83795fff6fc6c7189640142a0bebcc214
BLAKE2b-256 checksum
How to use checksums
404fbdcf2bc6633cfc2141cbc719a7f0e289b822f4b8998855b449194398ae15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Security for grid-sdk 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for grid_sdk-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page