← All use cases

Add an API endpoint

Point Sarvam Code at your service and describe the endpoint. It finds the routing, the handlers, and the tests, then writes the change to match.

Sarvam Code - api

Add a GET /v1/usage endpoint that returns the caller's monthly credit spend

I'll wire the route into the billing router and reuse the credits ledger query.

Edited src/routes/usage.rs (+4 -1)

18 let user = ctx.require_user().await?;
19- Ok(Json(json!({ "ok": true })))
19+ let spend = credits::month_to_date(&ctx.db, user.id).await?;
20+ Ok(Json(UsageResponse {
21+ micro_usd: spend.micro_usd,
22+ calls: spend.call_count,
23+ }))

Ran cargo test usage::

test usage::month_to_date_sums_calls ... ok

test result: ok. 1 passed

Endpoint live and the ledger sum is covered by a test. Ready to commit?

  1. 01Describe the endpoint in plain language, in English or an Indian language.
  2. 02The agent maps your routing layer, models, and existing handlers.
  3. 03It plans the change across the files it needs to touch and shows you the diff.
  4. 04You approve, it writes, and it runs your tests to confirm the route works.

Adding an endpoint is rarely one file. There is a route to register, a handler to write, a model or query to wire up, and a test to keep the suite green. Sarvam Code reads your project first so it follows your conventions instead of inventing its own.

Because every change is diffed and gated before it lands, you stay the operator: you see exactly what the agent intends to do, approve it, and let it run the verification loop. The result is a working endpoint that looks like the rest of your codebase wrote it.

Curious what it costs to run work like this? See cost per task, or the full pricing.

Related

Begin here

A gateway between people and intelligence. Join the early-access list and be first to ship with Sarvam Code.

$curl -fsSL https://dl.sarvamcode.com/install.sh | sh

Currently available for macOS only