Skip to main content

Python SDK for Xinference Cloud management APIs

Project description

Xinference Cloud Python SDK

Official Python SDK for the Xinference Cloud management APIs: browse the deployable model catalog, create and manage model deployments, and issue inference API keys — all from Python.

Installation

pip install xinference-cloud

Requires Python 3.11 or later. The only runtime dependency is httpx.

Authentication

The SDK authenticates with an SDK management credential scoped to your organization. You can obtain one in two ways:

  • Console UI — the SDK Credentials page in the Xinference Cloud console (in development, rolling out soon).

  • Management API — while signed in to the console, create one via POST /api/v1/organization/sdk-credentials:

    // Run in your browser DevTools console while signed in
    const res = await fetch("/api/v1/organization/sdk-credentials", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ name: "my-sdk-credential" }),
    });
    console.log((await res.json()).key);
    

The credential key is shown only once at creation time — store it securely. If you lose it, revoke the credential and create a new one.

Quickstart

from xinference_cloud import XinferenceCloud

client = XinferenceCloud(
    base_url="https://<your-region>.cloud.xinference.co",
    credential="<your-sdk-credential>",
)

with client:
    # Browse the deployable model catalog
    models = client.deployable_models.list(enabled_only=True)

    # Deploy a model and wait until it is running
    deployment = client.deployments.create(model_name="qwen2.5-instruct")
    deployment = client.deployments.wait(deployment["id"], timeout=600)

    # Issue an inference API key bound to the deployment
    api_key = client.inference_api_keys.create(
        name="production",
        deployment_ids=[deployment["id"]],
    )

Instead of passing arguments explicitly, you can set the XINFERENCE_CLOUD_BASE_URL and XINFERENCE_CLOUD_CREDENTIAL environment variables and construct the client with XinferenceCloud.from_env().

Resources

Resource Methods
client.deployable_models list, get
client.deployments create, list, list_page, get, wait, terminate, delete
client.inference_api_keys list, list_deployment_options, create, update, revoke

deployments.wait() polls a deployment until it reaches a target status (running by default), raises RuntimeError if it enters a failure status, and raises TimeoutError on timeout.

Error handling

API errors raise xinference_cloud.APIStatusError, which carries the HTTP status_code, the server error code (when provided), and the raw httpx.Response:

from xinference_cloud import APIStatusError

try:
    client.deployments.get("unknown-id")
except APIStatusError as exc:
    print(exc.status_code, exc.code, str(exc))

License

Apache-2.0

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

xinference_cloud-0.1.0.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

xinference_cloud-0.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file xinference_cloud-0.1.0.tar.gz.

File metadata

  • Download URL: xinference_cloud-0.1.0.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for xinference_cloud-0.1.0.tar.gz
Algorithm Hash digest
SHA256 697c3fa8778093d51a4659c0b1a5b591eac932b93fcf22f5ec297cf2f7183223
MD5 9d5f75cace8b0287d439aebf13b2bc16
BLAKE2b-256 1073cb9dc755ca49a6d6c38c0f7e340e3fefb601501b7b048c24f6d0546071a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for xinference_cloud-0.1.0.tar.gz:

Publisher: sdk-publish.yml on xorbitsai/xinference-saas

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

File details

Details for the file xinference_cloud-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for xinference_cloud-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5a3786017efab6d6198ddbece495141fd7613f659ae259c242b16132ddf1425
MD5 3ed79dd2f210fed67a0ea43cea75081f
BLAKE2b-256 2fe394a1b559459fb9396196f54c7ed072094a5155a9bc9b9028ef1e2383e154

See more details on using hashes here.

Provenance

The following attestation bundles were made for xinference_cloud-0.1.0-py3-none-any.whl:

Publisher: sdk-publish.yml on xorbitsai/xinference-saas

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

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