Skip to main content

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"))

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(...), and client.stream_message(...) for parsed streaming chunks with text, usage, and reasoning_tokens
  • client.models.list(...)
  • client.list_organisations(...) for paginated /organisations discovery
  • client.list_pricing_models(...) for /pricing/models catalogue pricing discovery
  • client.calculate_pricing(...) for /pricing/calculate usage estimation
  • client.list_providers(...), client.get_credits(...), client.get_activity(...), and client.get_analytics(...) for provider discovery and management-key usage surfaces
  • client.list_api_keys(...) for management-key /keys discovery
  • client.create_api_key(...), client.update_api_key(key_id, ...), and client.delete_api_key(key_id) for management-key API-key lifecycle changes
  • client.get_api_key(key_id) for management-key /keys/{id} lookup
  • client.list_workspaces(...), client.get_workspace(workspace_id), client.create_workspace(...), client.update_workspace(workspace_id, ...), and client.delete_workspace(workspace_id) for management-key workspace lifecycle management
  • client.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 :free in 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),
)

Environment variables

  • PHASEO_API_KEY (required unless passed in code)
  • PHASEO_BASE_URL (optional, defaults to https://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:chat
    • pnpm --filter @phaseo/py-sdk run smoke:responses

Download files

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

Source Distribution

phaseo-2.0.6.tar.gz (45.0 kB view details)

Uploaded Source

Built Distribution

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

phaseo-2.0.6-py3-none-any.whl (47.6 kB view details)

Uploaded Python 3

File details

Details for the file phaseo-2.0.6.tar.gz.

File metadata

  • Download URL: phaseo-2.0.6.tar.gz
  • Upload date:
  • Size: 45.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for phaseo-2.0.6.tar.gz
Algorithm Hash digest
SHA256 ad376d742e9312868de4f60dd32aaa61e7fbe3d80a095d18c1a692f57e649225
MD5 6720c26c2f6a3a977bd16811e302fb26
BLAKE2b-256 3766fb6bc3fe89175a87a72d0a30e0762b19400ff077f24eeab70a1a62c3575f

See more details on using hashes here.

Provenance

The following attestation bundles were made for phaseo-2.0.6.tar.gz:

Publisher: ci.yml on phaseoteam/Phaseo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phaseo-2.0.6-py3-none-any.whl.

File metadata

  • Download URL: phaseo-2.0.6-py3-none-any.whl
  • Upload date:
  • Size: 47.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for phaseo-2.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1089af81cd5e109dbd3e078db82ec23d87897306e01a7e01225ec92ff155a3cc
MD5 8531aab63d1d179c616b1f627ae4068f
BLAKE2b-256 9a395073e907aaf9a67c1eff41a806a089fce109fa5736161a5ee54cebc9ff7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for phaseo-2.0.6-py3-none-any.whl:

Publisher: ci.yml on phaseoteam/Phaseo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

2.0.7

2 files

This release

2.0.6 This release

2 files

2.0.5

2 files

2.0.4

2 files

Supported by

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