Docs

Python kit

Run open models from Python with the kit in the package store.

All docs

Example

Install it with: pip install corent. The package store has version 0.10.0.

Python
import os
import time

from corent import Corent

client = Corent(os.environ["CORENT_API_KEY"])

# What this key can run now, with the most each model can cost.
for model in client.open_available_models()["models"][:3]:
    print(model["model"], model["max_cost_cents"])

job = client.open_invoke(
    "corent/open/qwen-qwen3-4b-instruct-2507-ecefd4d6",
    {"prompt": "Say hello in one sentence.", "max_new_tokens": 64},
    max_cost_cents=19,
    idempotency_key="first-run-python-1",
)

# Read until it has ended. Reading never starts or charges anything.
finished = {"completed", "failed", "cancelled", "blocked", "expired"}
while job["state"] not in finished:
    time.sleep(5)
    job = client.open_invocation_status(job["id"])

print(job["state"], job["charge_cents"], "cents")
print(job["output"])

What success looks like

  • The program prints a few models, then "completed", the charge in cents and the answer.

If it fails

  • An error raises an exception that carries the status and message. Run it again with the same idempotency_key after a lost reply.
  • A method is missing: upgrade with pip install --upgrade corent.

Details

Open model methods

Python methods for open models
MethodWhat it does
open_modelsSearch the catalogue.
open_available_modelsWhat your key can run now, with the most each can cost.
open_invokeAsk for one run with a limit; it waits in line if needed.
open_invocation_statusRead a request and its result.
open_invocation_stopWithdraw a request that has not started.
open_runStart a text run at once, or be refused when busy.
open_generateThe same for any other kind of model.

A single call that waits for the result is not in the published kit yet. Use the loop above, or plain HTTP with ?wait.