API reference
Data import: Cost sources
Use your API key to declare non-LLM cost sources from CLI/import jobs.
This is the current Data import API surface. It lets a trusted CLI or backend import job declare cost sources that Pylva should track and price. It is not a general historical customer or event upload endpoint.
For the full coverage workflow, see Cost Source Discovery.
For tiered pricing, send
Authentication
Use your API key, as a bearer token or inX-Pylva-Key — the pylva CLI sends the bearer form and honors PYLVA_API_KEY (legacy PYLVA_CLI_KEY still works).
curl https://api.pylva.com/api/v1/cost-sources \
-X POST \
-H "Authorization: Bearer $PYLVA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"display_name": "Search API",
"slug": "search-api",
"source_type": "non_llm_manual",
"metric": "search_requests",
"unit": "request",
"price_per_unit": 0.01
}'
Request
{
"display_name": "Search API",
"slug": "search-api",
"source_type": "non_llm_manual",
"metric": "search_requests",
"unit": "request",
"price_per_unit": 0.01
}
pricing_tiers instead of price_per_unit:
{
"display_name": "Transcription API",
"slug": "transcription-api",
"source_type": "non_llm_manual",
"metric": "audio_minutes",
"unit": "minute",
"pricing_tiers": [
{ "from": 0, "to": 1000, "price": 0.006 },
{ "from": 1000, "to": null, "price": 0.004 }
]
}
Response
{
"cost_source": {
"id": "00000000-0000-0000-0000-000000000000",
"builder_id": "11111111-1111-1111-1111-111111111111",
"source_type": "non_llm_manual",
"display_name": "Search API",
"slug": "search-api",
"metric": "search_requests",
"unit": "request",
"price_per_unit": 0.01,
"pricing_tiers": null,
"status": "healthy",
"last_seen_at": null,
"approved_at": "2026-06-11T10:00:00.000Z",
"created_at": "2026-06-11T10:00:00.000Z"
}
}
Notes
- Re-running the same
slugis idempotent and returns the existing cost source. - Use this endpoint from server-side import jobs only.
- The same key also sends telemetry events and manages custom pricing — see API keys.