Docs
Client SDKs

Python Client

Typed Python management/discovery SDK plus official OpenAI SDK inference.

Published Python package

Qufas Python SDK 0.1.0 is the latest public PyPI release. This repository is 0.2.0, an unpublished development preview; it is available only by installing a repository checkout.

1python -m pip install qufas==0.1.0

Public 0.1.0 management and discovery surface

1import os2from qufas import Qufas3 4client = Qufas(api_key=os.environ["QUFAS_API_KEY"], base_url="https://qufas-ai.vercel.app")5models = client.models.list()6usage = client.usage.list(limit=25)7balance = client.billing.balance()8keys = client.api_keys.list()9 10print(models["data"][0]["id"])11print(usage["totals"]["total_tokens"])12print(balance["balance"], balance["currency"])13print(keys["data"][0]["name"])

Public 0.1.0 returns dictionaries for model, usage, balance, and API-key listing operations.

Chat uses the official OpenAI SDK

The Qufas Python package intentionally does not duplicate the OpenAI Chat client.

1import os2from openai import OpenAI3 4client = OpenAI(api_key=os.environ["QUFAS_API_KEY"], base_url="https://qufas-ai.vercel.app/v1")5response = client.chat.completions.create(6    model="kimi-k2.7-code",7    messages=[{"role": "user", "content": "Hello"}],8)9print(response.choices[0].message.content)

Errors and request IDs

Public 0.1.0 exposes the response status as status_code, the stable error code as error_code, and the server message through the exception string. Repository 0.2.0 adds richer typed error metadata.

1from qufas import Qufas, QufasAPIError2 3client = Qufas(api_key="qf_sk_...", base_url="https://qufas-ai.vercel.app")4try:5    client.models.list()6except QufasAPIError as error:7    print(error.status_code, error.error_code, str(error))

Generation observability

These methods are an unpublished repository 0.2.0 preview and are not available from qufas==0.1.0. Install the repository checkout shown above before using this example.

1# Requires repository preview 0.2.0, not the public PyPI package2import os3from qufas import Qufas4 5client = Qufas(api_key=os.environ["QUFAS_API_KEY"], base_url="https://qufas-ai.vercel.app")6generations = client.generations.list(limit=20)7generation = client.generations.retrieve("req_original")8image = client.images.generate(model="<enabled-image-model-id>", prompt="A small robot")9 10print(image.data[0].url, image.request_id)11print(generations.has_more, generations.next_cursor, generations.request_id)12print(generation.id, generation.status, generation.request_id)

client.generations.list and client.generations.retrievereturn immutable typed metadata. A Generation's error describes an inference outcome and does not raise QufasAPIError when the lookup itself returned HTTP 200. Monetary cost fields remain decimal strings.

Unavailable resources

API key create/delete, analytics summary, and credit transactions are compatibility stubs only. They raise NotImplementedError locally and are not stable public features.

Was this page helpful?