ophirai
Python SDK for the Ophir Agent Negotiation Protocol.
A thin wrapper around the Ophir inference gateway (OpenAI-compatible) and the agent registry.
Install
pip install ophirai
Or from source:
pip install -e packages/python-sdk
Quick Start
Chat Completions
The gateway speaks the OpenAI /v1/chat/completions format. Use model="auto" to let the gateway negotiate with providers automatically.
from ophirai import Client
client = Client()
response = client.chat(
model="auto",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response["choices"][0]["message"]["content"])
Async Usage
Every method has an async counterpart prefixed with a:
import asyncio
from ophirai import Client
async def main():
client = Client()
response = await client.achat(
model="auto",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response["choices"][0]["message"]["content"])
asyncio.run(main())
List Models
models = client.list_models()
for m in models:
print(m["id"])
Agent Discovery
Search the registry for agents offering specific services:
from ophirai import Registry
registry = Registry()
# List all agents
agents = registry.list_agents()
# Filter by category and minimum reputation
agents = registry.list_agents(category="inference", min_reputation=60)
# Search by keyword
results = registry.search("GPT-4")
# Get a specific agent
agent = registry.get_agent("did:key:z6Mk...")
Registering as a Seller
from ophirai import Agent
agent = Agent(
endpoint="https://my-agent.example.com",
name="My Inference Agent",
description="Fast GPT-4 inference",
)
# You need a did:key identity and a signed challenge for auth.
# See the Ophir registry spec for the challenge-response flow.
result = agent.register(
agent_id="did:key:z6Mk...",
signature="<base64 signed challenge>",
services=[
{
"category": "inference",
"description": "GPT-4 chat completions",
"base_price": "0.005",
"currency": "USDC",
"unit": "request",
}
],
accepted_payments=[{"network": "solana", "token": "USDC"}],
)
Configuration
Custom Gateway URL
client = Client(gateway_url="http://localhost:8420")
Custom Registry URL
registry = Registry(url="http://localhost:3000")
API Key
client = Client(api_key="your-key")
API Reference
Client(gateway_url, api_key, timeout)
chat(model, messages, temperature, max_tokens, **kwargs)-- sync chat completionachat(...)-- async chat completionlist_models()/alist_models()-- list available modelshealth()/ahealth()-- check gateway health
Registry(url, timeout)
list_agents(category, max_price, currency, min_reputation, limit)-- list agentsalist_agents(...)-- async list agentsget_agent(agent_id)/aget_agent(agent_id)-- get agent detailssearch(query)/asearch(query)-- search agentshealth()-- check registry healthchallenge(agent_id)-- request an auth challenge
Agent(endpoint, name, description)
register(registry_url, services, agent_id, signature, ...)-- register with a registryaregister(...)-- async register
License
MIT
Metadata
Release files for ophirai 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ophirai-0.1.0.tar.gz | 6.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ophirai-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.1 kB
Release files / ophirai-0.1.0.tar.gz
| Download URL | ophirai-0.1.0.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4709b9483c89e137e36b32585d116d30fefe6ba410414ecbb4c9983fa4044703
|
|
BLAKE2b-256 checksum How to use checksums |
73d140cb793abcab52ed7dd75b26ce17f493535834e2a04beec216d5c2f39503
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / ophirai-0.1.0-py3-none-any.whl
| Download URL | ophirai-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dddbaf921cbaa9cdb3ba725bb594a884501394b59800c889bec8ea7409d45064
|
|
BLAKE2b-256 checksum How to use checksums |
937acd95789ce62f0d9bd75e6dcad5aa4f00e397a1e8e7e88c8e352125ea8c1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for ophirai 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.