Docs
Python kit
Run open models from Python with the kit in the package store.
Example
Install it with: pip install corent. The package store has version 0.10.0.
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
| Method | What it does |
|---|---|
| open_models | Search the catalogue. |
| open_available_models | What your key can run now, with the most each can cost. |
| open_invoke | Ask for one run with a limit; it waits in line if needed. |
| open_invocation_status | Read a request and its result. |
| open_invocation_stop | Withdraw a request that has not started. |
| open_run | Start a text run at once, or be refused when busy. |
| open_generate | The 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.