Inference API

Call your prompts and chains programmatically with a pv_live_ API key, selecting the version slot to run.

API keys

Create an API key in Settings → API Keys. Keys are prefixed pv_live_, shown once at creation, and hashed at rest. You can scope a key to specific prompts and providers.

Calling a prompt

Send a POST to /inference with your key as a Bearer token. Use prompt_id (or chain_id for a chain) and choose the version slot — live/prod, staging, dev, or latest.

bash
curl -X POST https://your-host/api/v1/inference \
  -H "Authorization: Bearer pv_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt_id": "YOUR_PROMPT_ID",
    "version": "prod",
    "provider": "openai",
    "model": "gpt-4o",
    "variables": { "code_snippet": "..." }
  }'

In Python

python
import requests

response = requests.post(
    "https://your-host/api/v1/inference",
    headers={"Authorization": "Bearer pv_live_YOUR_API_KEY"},
    json={
        "prompt_id": "YOUR_PROMPT_ID",
        "version": "prod",
        "provider": "openai",
        "model": "gpt-4o",
        "variables": {"code_snippet": "..."},
    },
)
print(response.json())

In JavaScript

javascript
const response = await fetch("https://your-host/api/v1/inference", {
  method: "POST",
  headers: {
    Authorization: "Bearer pv_live_YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    prompt_id: "YOUR_PROMPT_ID",
    version: "prod",
    provider: "openai",
    model: "gpt-4o",
    variables: { code_snippet: "..." },
  }),
});
const data = await response.json();
Slots and A/B tests apply
The version field resolves through your deployment slots, and an active A/B test can intercept prod/live calls and route a share to variant B — automatically.