Phaseo Python SDK
Official Python SDK for Phaseo Gateway.
Installation
pip install phaseo
Requires Python 3.10+.
Quick start
from phaseo import Phaseo
client = Phaseo() # Uses PHASEO_API_KEY from environment
response = client.responses.create(
{
"model": "google/gemma-3-27b:free",
"input": "Reply with: Python SDK works",
}
)
print(response.get("output_text"))
To attribute usage to one of your own applications, provide app metadata explicitly:
client = Phaseo(
app={
"id": "support-console",
"name": "Support Console",
"url": "https://support.example.com",
}
)
App attribution is optional and is never inferred from the SDK itself.
Regional text routing
Select eu or us to restrict Chat Completions, Responses, and Messages to
matching regional provider routes:
client = Phaseo(region="eu")
Regional endpoints currently accept text-only requests. This is regional
provider routing, not an end-to-end data residency guarantee. region cannot be
combined with a custom base_url.
Streaming example
from phaseo import Phaseo
client = Phaseo()
response = ""
for chunk in client.stream_chat(
{
"model": "google/gemma-3-27b:free",
"messages": [{"role": "user", "content": "Stream hi"}],
}
):
if chunk.get("text"):
response += chunk["text"]
print(chunk["text"], end="", flush=True)
if chunk.get("reasoning_tokens"):
print("\nReasoning tokens:", chunk["reasoning_tokens"])
Common methods
client.responses.create(...)client.chat.completions.create(...)client.messages.create(...)client.stream_chat(...),client.stream_responses(...), andclient.stream_message(...)for parsed streaming chunks withtext,usage, andreasoning_tokensclient.models.list(...)client.list_organisations(...)for paginated/organisationsdiscoveryclient.list_pricing_models(...)for/pricing/modelscatalogue pricing discoveryclient.calculate_pricing(...)for/pricing/calculateusage estimationclient.list_providers(...),client.get_credits(...),client.get_activity(...), andclient.get_analytics(...)for provider discovery and management-key usage surfacesclient.list_api_keys(...)for management-key/keysdiscoveryclient.create_api_key(...),client.update_api_key(key_id, ...), andclient.delete_api_key(key_id)for management-key API-key lifecycle changesclient.get_api_key(key_id)for management-key/keys/{id}lookupclient.list_workspaces(...),client.get_workspace(workspace_id),client.create_workspace(...),client.update_workspace(workspace_id, ...), andclient.delete_workspace(workspace_id)for management-key workspace lifecycle managementclient.get_current_api_key()client.get_health()client.models.get_deprecation_info(model_id)client.models.validate(model_id)client.batches.list_models()for batch-capable models and supported batch parameter metadata
Model discovery supports the public /models filters, including provider, provider_status, provider_routing_status, model_routing_status, capability_status, provider_availability_status, provider_availability_reason, status, organisation, endpoints, input_types, output_types, params, availability, limit, and offset.
Use provider_availability_reason with availability="all" when you want rollout-state entries such as preview_only, provider_not_ready, gated, access_limited, region_limited, project_limited, paused, or soft_blocked. Use capability_status with availability="all" when you want non-routable endpoint mappings such as coming_soon or internal_testing.
models = client.get_models({
"provider": ["anthropic"],
"provider_status": ["beta", "not_ready"],
"provider_availability_reason": ["preview_only", "provider_not_ready"],
"capability_status": ["coming_soon", "internal_testing"],
"availability": "all",
})
Async job websocket helpers
Batch and video operations can expose a websocket lifecycle stream at /v1/async/{kind}/{id}/ws.
Create responses include the job id, polling URL, optional websocket URL, and sanitized webhook delivery state.
import os
batch = client.batches.create({
"endpoint": "/v1/responses",
"input_file_id": "file_123",
"completion_window": "24h",
"webhook": {
"url": "https://example.com/phaseo/webhooks",
"secret": os.environ["PHASEO_WEBHOOK_SECRET"],
"events": ["batch.progress", "batch.completed", "batch.failed"],
},
})
video = client.videos.create({
"model": "google/veo-3",
"prompt": "orbital reveal",
"webhook": {
"url": "https://example.com/phaseo/webhooks",
"secret": os.environ["PHASEO_WEBHOOK_SECRET"],
"events": ["video.progress", "video.completed", "video.failed"],
},
})
batch_socket_url = client.batches.websocket_url("batch_123", interval_ms=1500)
video_socket_url = client.videos.websocket_url(
"video_123",
close_on_terminal=True,
)
generic_socket_url = client.get_async_job_websocket_url("video", "video_123")
Free and paid models
- Models with
:freein the model ID can be called with zero deposited credits. - Paid models require available wallet balance.
Model lifecycle warnings
from phaseo import Phaseo
client = Phaseo(
enable_deprecation_warnings=True,
warnings_as_errors=False,
logger=lambda level, message, meta: print(level, message, meta),
)
For completed Anthropic batches, client.batches.stream_results(batch_id) yields original JSONL byte chunks without buffering the whole download. Write chunks to your output file and close the iterator if stopping early. The configured HTTP timeout applies; downloading does not add inference charges.
Environment variables
PHASEO_API_KEY(required unless passed in code)PHASEO_BASE_URL(optional, defaults tohttps://api.phaseo.app/v1)
Devtools
from phaseo import Phaseo, create_phaseo_devtools
client = Phaseo(
devtools=create_phaseo_devtools(
directory=".phaseo-devtools",
capture_headers=False,
)
)
Regeneration and local checks
- Regenerate generated client:
pnpm openapi:gen:py - Run tests:
pnpm test:sdk-py - Smoke checks:
pnpm --filter @phaseo/py-sdk run smoke:chatpnpm --filter @phaseo/py-sdk run smoke:responses
Metadata
Release files for phaseo 3.0.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 | Actions |
|---|---|---|---|---|
| phaseo-3.0.0.tar.gz | 67.3 kB | With provenance | Details for phaseo-3.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| phaseo-3.0.0-py3-none-any.whl | Python 3 | none | any | Details for phaseo-3.0.0-py3-none-any.whl |
Total release size: 137.3 kB
Release files / phaseo-3.0.0.tar.gz
| Download URL | phaseo-3.0.0.tar.gz |
|---|---|
| Size | 67.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ca2c7e4d69d908ac4a4fbf753e8da70095a4b57b74066a1b75a3bf6910891ae
|
|
BLAKE2b-256 checksum How to use checksums |
0207842b68f78f5fc417e7a1128a902aa85c21676964710e9c9821c7edd4092a
|
| 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 Sep 17, 2026.
Transparency logRelease files / phaseo-3.0.0-py3-none-any.whl
| Download URL | phaseo-3.0.0-py3-none-any.whl |
|---|---|
| Size | 70.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
864a2dbfdfea268c78e57fb4e3a2d303540135cb88374343e3214377c5e8be23
|
|
BLAKE2b-256 checksum How to use checksums |
38d84464717a158d064ceef34409a32cb6504cb20ba3521a5c7037c47acf05f5
|
| 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 Sep 17, 2026.
Transparency logSecurity for phaseo 3.0.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for phaseo-3.0.0.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 Sep 17, 2026.
Transparency logA 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.