Sign in Get started

Deployments

Turn a trained model into an always-on inference endpoint - per-deployment bearer token, one /predict URL, billed by uptime. SDK, CLI, and REST.

View as Markdown

A deployment turns a trained model into an always-on inference endpoint. You create it, get a pk_deploy_ token and a /predict URL, and call that URL from REST, the SDK, or the CLI. Billing is by uptime, so pause it when idle to stop the meter.

Source: resources/deployments.py. Full method surface: Deployments API reference.

from pictograph import Client, CreatedDeployment

client = Client()

created: CreatedDeployment = client.deployments.create(
    model="Swift Falcon",
    gpu_type="t4",
    min_containers=1,
)
print(created.deployment.endpoint_url)
print(created.auth_token)   # pk_deploy_... also revealable from Settings

The deployment starts in provisioning. Poll client.deployments.get(name) until status is active, then call it.

Calling the endpoint

One /predict URL, secured by its own bearer token, not your X-API-Key. Only the token’s hash is stored, so it cannot be recovered later.

Source: resources/_deployment_client.py

from pictograph import DeploymentClient, DetectionResult

infer = DeploymentClient(
    endpoint=created.deployment.endpoint_url,   # already ends in /predict
    api_key="pk_deploy_...",                    # from create, or Settings
    task="object_detection",
)
result: DetectionResult = infer.infer(image="./frame.jpg")   # path | URL | bytes

for p in result.predictions:
    print(p.name, round(p.confidence, 2), p.bounding_box)

infer() returns the same typed result classes a local model returns, so code that runs a model on your own hardware and code that calls a deployment are the same code. task= narrows the return type and is verified against what the endpoint reports. Use infer_raw() for the untouched JSON body.

# Multipart - simplest, but options fall back to the deployment's defaults.
curl -X POST "$ENDPOINT_URL" \
  -H "Authorization: Bearer pk_deploy_..." \
  -F "file=@frame.jpg"

# JSON - carries confidence / class_filter / top_k inline.
curl -X POST "$ENDPOINT_URL" \
  -H "Authorization: Bearer pk_deploy_..." \
  -H "Content-Type: application/json" \
  -d '{"image": {"type": "url", "value": "https://example.com/frame.jpg"}, "confidence": 0.4}'
pictograph deployments predict "prod-detector" ./frame.jpg \
  --token pk_deploy_... --endpoint https://…/predict

Billing

Metered by uptime in USD compute credits. Three levers:

  • Pause and resume - pause stops the meter; resume takes seconds.
  • Scale to zero - min_containers=0 bills only while actually serving, at the cost of a short cold start on the first request after idle.
  • Auto-pause - the deployment pauses itself if your balance reaches zero.

Every metering window is recorded, and client.deployments.quote(...) gives you the rate before you create anything.

Deployment or workflow?

A deployment is an always-on endpoint you call, right for low-latency inference behind a stable URL. A workflow loads the model’s weights per run, so batch and video jobs need no deployment at all.

Next steps

Copied to clipboard