DevTools AI

API Reference

One Route Handler serves every tool: POST /api/ai/[slug], where slug is any tool slug from config/tools.config.ts.

Request body

{
  "input": { "input": "...", "language": "TypeScript" },
  "model": "qwen/qwen3-coder:free",
  "temperature": 0.4,
  "maxTokens": 2048
}

inputis a flat string-keyed object — its exact shape depends on the tool’s fields. model must be one of the IDs in config/models.ts.

Response

On success, the response body is a raw UTF-8 text stream (Content-Type: text/plain) — the completion, streamed as it’s generated. There is no JSON envelope on success.

On failure, the response is JSON:

{
  "error": { "message": "...", "code": "VALIDATION_ERROR" }
}

Error codes

CodeStatusMeaning
VALIDATION_ERROR400Request body or tool input failed schema validation
TOOL_NOT_FOUND404The slug doesn’t match a registered tool
MODEL_NOT_ALLOWED400The requested model isn’t in the allowlist
MISSING_API_KEY500OPENROUTER_API_KEYisn’t set on the server
RATE_LIMITED429OpenRouter rate-limited the request
UPSTREAM_ERROR502OpenRouter returned a non-2xx response

Available tool slugs

  • code-explainer
  • bug-finder
  • commit-message-generator
  • readme-generator
  • regex-generator
  • sql-generator
  • json-to-typescript
  • email-generator
  • code-optimizer
  • code-reviewer