RunAPI core SDK for JavaScript, Python, Ruby, Go, Java, and PHP
Project description
RunAPI Core Python SDK
The RunAPI Core Python SDK provides shared authentication, HTTP, retry, error, and polling primitives for RunAPI model packages. Install runapi-core only when you are building SDK infrastructure or shared Python tooling; application code should normally install a concrete model package such as runapi-flux-2.
Install
pip install runapi-core
Notes
Use the core package for common client options, error classes, request helpers, file uploads, live pricing, account resources, and task polling behavior that Provider Clients share. Configure it globally or per client:
import runapi.core as runapi
runapi.configure(api_key="sk-...") # or set RUNAPI_API_KEY in the environment
Request identifiers
RunAPI accepts an optional X-Client-Request-Id header on public API calls. Use printable ASCII values up to 512 characters. Accepted values are echoed in the response and stored with the RunAPI task for support and reconciliation.
Task-creation calls also accept an optional opaque Idempotency-Key up to 512 characters. Generate one value per logical task and reuse it only with identical input after an unknown result. Reusing the value with different input returns 409 Conflict; do not derive it from X-Client-Request-Id.
High-level Python Provider Client resource methods accept per-request options and keep response headers on the returned model object. This example uses the Suno Provider Client; install runapi-suno to run it.
import os
from runapi.core import RequestOptions
from runapi.suno import SunoClient
client = SunoClient(api_key=os.environ["RUNAPI_API_KEY"])
options = RequestOptions(
headers={
"X-Client-Request-Id": "order-123",
"Idempotency-Key": "opaque-logical-task-123",
},
)
response = client.text_to_music.create(
prompt="A chill lo-fi beat",
model="suno-v4.5-plus",
vocal_mode="instrumental",
options=options,
)
runapi_task_id = response.runapi_task_id
# Equivalent case-insensitive lookup:
runapi_task_id = response.response_headers["X-RunAPI-Task-Id"]
from runapi.core import FilesClient
files = FilesClient() # reads RUNAPI_API_KEY, or pass api_key="sk-..."
uploaded = files.create(file="./input.png")
remote = files.create(source="https://cdn.runapi.ai/public/samples/input.png")
inline = files.create(source="iVBORw0KGgo...")
print(uploaded.url)
Public SDK docs live at https://runapi.ai/docs#runapi-sdks and the model catalog lives at https://runapi.ai/models.
Universal resources
Every Provider Client exposes files, account, and pricing through one shared HTTP client. pricing.list_schedules() reads the current schedule, and pricing.create_quote() estimates a reservation without creating a Task. The schedule and ordinary quote calls do not require an API key; a quote that uses an existing Task as pricing context requires the key for that Task's Account.
from runapi.core import RequestOptions
from runapi.flux import FluxClient
client = FluxClient(api_key="sk-...")
schedules = client.pricing.list_schedules(
service="flux",
action="text_to_image",
options=RequestOptions(headers={"If-None-Match": '"previous-etag"'}),
)
quote = client.pricing.create_quote(
service="flux",
action="text_to_image",
model="flux-pro",
params={"prompt": "A glass observatory"},
)
Task responses expose persisted billing facts at response.billing: reservation, settlement, and refund are typed objects when recorded and None when the historical fact is absent. These facts describe that Task and are not recalculated from the current schedule.
License
Licensed under the Apache License, Version 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file runapi_core-0.3.2.tar.gz.
File metadata
- Download URL: runapi_core-0.3.2.tar.gz
- Upload date:
- Size: 31.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
708eb23fb05f7d3a1d65730bea39a81e04f0fbdde143cba4aa3b1db061c9c8d3
|
|
| MD5 |
cbb93b7331b7159e932f6223c1051921
|
|
| BLAKE2b-256 |
153b2876eb9ed9017c5a1cddef1c988e19d7261c8a64552f2e098beb6b0653dc
|
File details
Details for the file runapi_core-0.3.2-py3-none-any.whl.
File metadata
- Download URL: runapi_core-0.3.2-py3-none-any.whl
- Upload date:
- Size: 28.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f499d79cc75375dd9a3860ec72bf6dc86608d356b64188492a4486b5cecfd08
|
|
| MD5 |
506d519351bf62385874a0f8e1898de2
|
|
| BLAKE2b-256 |
7db05490ae61034939eef628c1f32611beabe394e6d78e70bfa2f63b35d0c26a
|