Generate code from a natural language prompt. The Theo Code engine is optimized for production-quality code and long-form output.
Authentication
Requires a Bearer token. See Authentication.
Request Body
Description of the code to generate.
Target programming language (e.g., "typescript", "python", "go", "rust"). Appended as a hint to the engine.
Target framework (e.g., "express", "nextjs", "fastapi", "gin"). Appended as a hint to the engine.
Request Examples
curl -X POST https://hitheo.ai/api/v1/code \
-H "Authorization: Bearer $THEO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Write a TypeScript Express middleware for JWT authentication",
"language": "typescript",
"framework": "express"
}'
Response
Unique code generation ID (prefixed code_).
The generated code as text.
Any files created during generation (e.g., multi-file outputs).
Tools invoked during code generation.
Example Response
{
"id": "code_abc123",
"created": "2026-04-10T12:00:00Z",
"content": "import { Request, Response, NextFunction } from 'express';\nimport jwt from 'jsonwebtoken';\n\nexport function authMiddleware(req: Request, res: Response, next: NextFunction) {\n const token = req.headers.authorization?.split(' ')[1];\n if (!token) return res.status(401).json({ error: 'No token provided' });\n try {\n const decoded = jwt.verify(token, process.env.JWT_SECRET!);\n req.user = decoded;\n next();\n } catch {\n return res.status(401).json({ error: 'Invalid token' });\n }\n}",
"artifacts": [],
"tools_used": [],
"usage": { "cost_cents": 0.05 }
}
Errors
| Status | Code | Description |
|---|
| 400 | missing_prompt | prompt is required |
| 401 | invalid_api_key | Missing or invalid API key |
| 429 | rate_limit_exceeded | Too many requests |