BrainAPI Developer Hub

Quickstart

Create an API key and call BrainAPI in under 5 minutes.

curl -X POST "$BASE_URL/api/v1/public/signup-trial" \
-H "Content-Type: application/json" \
-d '{
 "name":"Demo User",
 "email":"demo@example.com",
 "company":"Demo Labs",
 "use_case":"AI assistant",
 "source":"website",
 "consent":true
}'

Text Generation

curl -X POST "$BASE_URL/api/v1/text/generate" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "prompt":"Write startup launch copy",
 "temperature":0.6,
 "max_output_tokens":200
}'

Image Generation

curl -X POST "$BASE_URL/api/v1/image/generate" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
 "prompt":"Modern SaaS dashboard UI",
 "size":"1024x1024"
}'

Python Example

import httpx

api_key = "YOUR_API_KEY"

res = httpx.post(
 "http://localhost:8000/api/v1/text/generate",
 headers={"x-api-key": api_key},
 json={"prompt":"Hello world"}
)

print(res.json())

Common Errors

Code Meaning
401 Invalid API key
402 Trial expired
429 Rate limit exceeded
500 Provider error