Endpoint reference
Code generation
POST /v1/code/generate · Synchronous
This route accepts strict JSON. Unknown fields, malformed values, wrong-operation keys, and package settings outside the locked configuration are rejected before provider execution.
Required headers
| Header | Value | Notes |
|---|---|---|
Authorization | Bearer $URTHEPRODUCT_API_KEY | Required. Must be sent from a trusted server. |
Idempotency-Key | 8–128 safe characters | Required on POST. Reuse only for retries of the same logical request. |
Content-Type | application/json | Required on POST. |
Request fields
| Field | Type | Required | Rules |
|---|---|---|---|
input | string | Yes | 1–64,000 characters of code, schema, error context, or requirements. |
language | string | No | 1–80 character language or dialect hint. |
requirements | string[] | No | Up to 30 entries, each up to 500 characters. |
Request example
curl "https://urtheproduct.com/v1/code/generate" \
+ -X POST \
+ -H "Authorization: Bearer $URTHEPRODUCT_API_KEY" \
+ -H "Idempotency-Key: logical-request-001" \
+ -H "Content-Type: application/json" \
+ -d '{ "input": "export function add(a:number,b:number){return a+b}", "language": "typescript", "requirements": ["Generate Vitest cases", "Do not execute code"]}'{
"input": "export function add(a:number,b:number){return a+b}",
"language": "typescript",
"requirements": ["Generate Vitest cases", "Do not execute code"]
}Success response
{
"id": "usage-event-id",
"object": "generation",
"operation": "code.generate",
"output": { "code": "...", "explanation": "..." },
"usage": { "charged_units": 1, "remaining_units": 99 }
}Operation-specific behavior
- Code engines analyze supplied content; they do not execute code unless a future published package explicitly states otherwise.
- Review, test, and security-scan generated code before use.
Failures and retries
Schema failures return 422 validation_error without charging quota. Wrong scope returns 403 forbidden. Rate/concurrency pressure returns 429 rate_limited. Provider safety pauses return 503 provider_unavailable. Follow the error and retry table and reuse the same idempotency key for the same logical request.