Zynexa Docs

Quick Start & API Reference

Integrate SDKs, export usage data, review suggestions, and explore experimental routing/cache endpoints.

SDK Setup

Python

pip install costpilot

import costpilot
costpilot.init(api_key="cp_xxx")

Node.js

npm install costpilot

import { init } from 'costpilot';
init({ apiKey: 'cp_xxx' });
API Endpoints
POST
/api/v1/events

Track Events

curl -X POST "$BASE/api/v1/events" \
  -H "Authorization: Bearer cp_xxx" \
  -H "Content-Type: application/json" \
  -d '{"provider":"openai","model":"gpt-4o","prompt_tokens":1200,"completion_tokens":400}'
GET
/api/v1/export?format=csv&from=2026-03-01T00:00:00Z

Export Logs (CSV)

curl -H "Authorization: Bearer cp_xxx" \
  "$BASE/api/v1/export?format=csv&include_content=true" -o events.csv
GET
/api/v1/suggestions

Suggestions

POST is accepted as a backwards-compatible alias.

curl -H "Authorization: Bearer cp_xxx" \
  "$BASE/api/v1/suggestions"
POST
Experimental
/api/v1/route-model

Route Model

Experimental routing guidance; validate recommendations before production use.

curl -X POST "$BASE/api/v1/route-model" \
  -H "Authorization: Bearer cp_xxx" \
  -H "Content-Type: application/json" \
  -d '{"objective":"balanced","estimatedPromptTokens":1200,"estimatedCompletionTokens":400}'
POST
Experimental
/api/v1/proxy

Proxy (Cache + Routing)

Experimental helper response; this endpoint does not call the upstream provider for you.

curl -X POST "$BASE/api/v1/proxy" \
  -H "Authorization: Bearer cp_xxx" \
  -H "Content-Type: application/json" \
  -d '{"provider":"openai","model":"gpt-4o","prompt":"Summarize this...","objective":"cost"}'
GET
Experimental
/api/v1/cache?provider=openai&model=gpt-4o&prompt=Hello

Cache Lookup

Experimental cache primitive for direct cache lookups.

curl -H "Authorization: Bearer cp_xxx" \
  "$BASE/api/v1/cache?provider=openai&model=gpt-4o&prompt=Hello"
POST
Experimental
/api/v1/cache

Cache Store

Experimental cache primitive for explicit cache writes.

curl -X POST "$BASE/api/v1/cache" \
  -H "Authorization: Bearer cp_xxx" \
  -H "Content-Type: application/json" \
  -d '{"provider":"openai","model":"gpt-4o","prompt":"Hello","response_content":"Hi there!","ttl_seconds":3600}'
GET
/api/v1/forecast?lookback_days=30&horizon_days=7

Forecast

curl -H "Authorization: Bearer cp_xxx" \
  "$BASE/api/v1/forecast?lookback_days=30&horizon_days=7"
Prompt Versioning & Team

Open /dashboard/prompts to manage prompt versions, or /dashboard/team to manage team members.

Use prompt versions to roll back templates safely without editing live content directly.

Team members can accept pending invitations sent to their account email before accessing a project.