API documentation
Control AI cost in three requests.
Use CostVane beside your existing model-provider integration. Estimate a request, evaluate budgets, then record actual usage—without sending prompts, outputs, or provider credentials.
https://api.costvane.comQuickstart
Send token counts and the provider/model identifier to receive a detailed estimate.
curl https://api.costvane.com/v1/estimate \
-X POST \
-H "X-API-Key: $COSTVANE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"provider": "openai",
"model": "gpt-5.4-mini",
"inputTokens": 1000,
"cachedInputTokens": 500,
"outputTokens": 200
}'{
"provider": "openai",
"model": "gpt-5.4-mini",
"totalCost": 0.00069,
"inputCost": 0.000375,
"cachedInputCost": 0.000019,
"outputCost": 0.0003,
"currency": "USD",
"pricingSource": {
"type": "official",
"url": "https://developers.openai.com/api/docs/pricing"
}
}Authentication
All /v1 endpoints require an API key in the X-API-Key request header. Keep keys server-side and never expose them in browser code or public repositories.
Production keys are currently issued during onboarding. Email support@costvane.com to request access.
/v1/estimateEstimate a request
Returns input, cached-input, output, and total cost using the versioned provider catalog. Use it for price previews and routing decisions.
providerstringopenai, anthropic, google, or openroutermodelstringCatalog model identifierinputTokensintegerNon-cached input tokenscachedInputTokensintegerOptional cached input tokensoutputTokensintegerGenerated output tokens/v1/preflightEvaluate budgets before execution
Combines a cost estimate with every matching active budget and returns allow, warn, or block.
{
"provider": "anthropic",
"model": "claude-sonnet-4-5",
"inputTokens": 4200,
"outputTokens": 900,
"customerId": "cust_123",
"feature": "research-agent"
}/v1/usageRecord actual usage
Send the provider-reported actual cost when available. Add an Idempotency-Key header so network retries do not double-count the event.
{
"provider": "openai",
"model": "gpt-5.4-mini",
"inputTokens": 1000,
"outputTokens": 200,
"actualCost": 0.00072,
"customerId": "cust_123",
"feature": "copilot",
"environment": "production",
"tags": { "plan": "pro" }
}/v1/usage/summarySummarize and attribute spend
Query by period=day|week|month and optionally group by customer, feature, workflow, team, project, or environment.
GET /v1/usage/summary?period=month&groupBy=customerBudgets
Create dollar or token limits with POST /v1/budgets. Budgets can apply globally or to a customer, feature, workflow, team, project, or environment. Enforcement can warn or block.
Webhooks
Register an HTTPS endpoint with POST /v1/webhooks. CostVane encrypts the signing secret at rest and signs events using HMAC-SHA256. Private-network destinations are rejected.
Errors and request IDs
Error responses use a stable code and a safe human-readable message. Every response includes an X-Request-Id header for support and log correlation.
400Invalid requestCheck the payload and model identifier401UnauthorizedSupply a valid X-API-Key429Rate or quota limitRetry later or upgrade the plan