Code Generate API
Generate working code from natural language descriptions via REST API using Claude. Describe what you want the code to do, specify the programming language, and receive production-ready code with comments explaining the implementation.
Try it live →How it works
POST a description of the code you need and a target language (JavaScript, Python, Go, Rust, SQL, etc.). Optionally specify framework constraints or style requirements. Returns the generated code and an explanation of how it works.
Use cases
- Prototype functions quickly from specifications in agent workflows
- Generate boilerplate code for common patterns (CRUD, auth, validation)
- Create code examples for documentation or tutorials automatically
- Convert pseudocode or algorithm descriptions into working implementations
- Generate scripts for DevOps automation from plain-English descriptions
API Reference
POST https://slopshop.gg/v1/llm-code-generate
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Input parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
text |
string | required | The text to process with AI |
options |
object | optional | Optional configuration (format, length, etc.) |
Example response
{
"data": {
"result": "AI-generated result based on your input.",
"model": "claude-3-5-sonnet",
"tokens_used": 150
},
"meta": {
"credits_used": 20,
"engine": "real",
"ms": 4
}
}
Examples
Three real-world scenarios showing how developers use Code Generate in production.
curl -X POST https://slopshop.gg/v1/llm-code-generate \
-H "Authorization: Bearer $SLOPSHOP_KEY" \
-H "Content-Type: application/json" \
-d '{"description": "Express POST /users route that validates email and password, hashes the password with bcrypt, and inserts into a PostgreSQL users table", "language": "javascript"}'
curl -X POST https://slopshop.gg/v1/llm-code-generate \
-H "Authorization: Bearer $SLOPSHOP_KEY" \
-H "Content-Type: application/json" \
-d '{"description": "Python function that takes a list of user dicts with nested address objects and flattens them to a CSV-compatible format", "language": "python"}'
curl -X POST https://slopshop.gg/v1/llm-code-generate \
-H "Authorization: Bearer $SLOPSHOP_KEY" \
-H "Content-Type: application/json" \
-d '{"description": "PostgreSQL migration to create a marketplace_submissions table with slug, name, credits, status, and created_at columns, with a unique index on slug", "language": "sql"}'
Code examples
curl
curl -X POST https://slopshop.gg/v1/llm-code-generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"input": "your data here"}'
Python
import requests
response = requests.post(
"https://slopshop.gg/v1/llm-code-generate",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"input": "your data here"}
)
result = response.json()
print(result["data"])
Node.js
const response = await fetch("https://slopshop.gg/v1/llm-code-generate", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({ input: "your data here" })
});
const { data } = await response.json();
console.log(data);
CLI
# Install the Slopshop CLI
npm install -g slopshop
# Set your API key
export SLOPSHOP_KEY=your_api_key
# Call llm-code-generate
slop llm-code-generate '{"input": "your data here"}'
Pricing
Credits are purchased in bundles starting at $1 for 1,000 credits. All compute APIs like this one use 20 credits per call — that's $0.02. See all pricing tiers.
Related APIs in AI: Code
View the full API catalog · Try in playground · Documentation