Skip to main content
POST
/
api
/
v1
/
code
Generate Code
curl --request POST \
  --url https://api.example.com/api/v1/code \
  --header 'Content-Type: application/json' \
  --data '
{
  "prompt": "<string>",
  "language": "<string>",
  "framework": "<string>"
}
'
{
  "id": "<string>",
  "created": "<string>",
  "content": "<string>",
  "artifacts": [
    {}
  ],
  "tools_used": [
    {
      "name": "<string>",
      "status": "<string>"
    }
  ],
  "usage": {
    "cost_cents": 123
  }
}
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

prompt
string
required
Description of the code to generate.
language
string
Target programming language (e.g., "typescript", "python", "go", "rust"). Appended as a hint to the engine.
framework
string
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

id
string
Unique code generation ID (prefixed code_).
created
string
ISO 8601 timestamp.
content
string
The generated code as text.
artifacts
object[]
Any files created during generation (e.g., multi-file outputs).
tools_used
object[]
Tools invoked during code generation.
usage
object

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

StatusCodeDescription
400missing_promptprompt is required
401invalid_api_keyMissing or invalid API key
429rate_limit_exceededToo many requests