API Reference

Access your SpacePrompts prompts using your personal API key. Available on the Pro and Team plans.

Authentication

All requests must include your API key in the X-API-Key header. You can generate or view your API key from your Account Settings.

Header
X-API-Key: {YOUR_API_KEY}
Never share your API key or commit it to public repositories.

Base URL

https://services.spaceprompts.com/api/v2

Rate Limits

All endpoints are rate limited to 60 requests per minute per API key. Requests exceeding this limit will receive a 429 Too Many Requests response.

Endpoints

GET/prompts/{slug}

Retrieve a prompt by its slug. Only returns prompts owned by the API key holder.

Path Parameters

ParameterTypeDefaultDescription
slugstringThe unique slug of the prompt

URL Parameters

ParameterTypeDefaultDescription
response_formatstringjsonResponse format. Use text to return the system prompt as plain text only.

Example Requests

JSON (default)

curl -X GET "https://services.spaceprompts.com/api/v2/prompts/{slug}" \
  -H "X-API-Key: {YOUR_API_KEY}"

Example Response

200 OK
{
  "title": "AI Code Reviewer - Security & Performance",
  "category": "Technology",
  "tags": ["code-review", "debugging", "code-quality", "software-engineering"],
  "prompt": "You are an expert code reviewer. Analyze the provided code and deliver a structured, actionable review focused on functionality, security, performance, and maintainability."
}
POST/prompts/run/{slug}

Run a stored prompt against your input. Provide the prompt's slug and a query. SpacePrompts retrieves the prompt and runs it through the default AI model, returning the generated response.

Request Body

FieldTypeRequiredDescription
querystringNoThe user message to send to the AI model

URL Parameters

ParameterTypeDefaultDescription
response_formatstringjsonResponse format. Use text to return the AI result as plain text only.

Example Requests

JSON (default)

curl -X POST "https://services.spaceprompts.com/api/v2/prompts/run/{slug}" \
  -H "X-API-Key: {YOUR_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"query": "Hey, can you send that over?"}'

Example Response

200 OK
{
  "prompt": "Convert this sentence to formal business English.",
  "query": "Hey, can you send that over?",
  "result": "Could you please forward that document at your earliest convenience?"
}
GET/token-count

Count tokens for a given prompt and model using model-specific tokenizers.

URL Parameters

ParameterTypeRequiredDescription
promptstringYesThe text to count tokens for
modelstringYesOne of: openai, claude, gemini, deepseek

Supported Models

AliasModel
openaiGPT-5.4
claudeClaude Sonnet 4.6
geminiGemini 3.1 Pro Preview
deepseekDeepSeek V3.2

Example Requests

curl -X GET "https://services.spaceprompts.com/api/v2/token-count?prompt=You+are+an+expert+code+reviewer&model=gemini" \
  -H "X-API-Key: {YOUR_API_KEY}"

Example Response

200 OK
{
  "model": "gemini",
  "token_count": 9,
  "character_count": 38
}
POST/prompts/enhance

Enhance a prompt using AI. Analyzes the prompt for issues and returns an improved version. Uses the same enhancement quota as the dashboard.

Request Body

FieldTypeRequiredDescription
promptstringYesThe prompt text to enhance (max 3,000 characters)

URL Parameters

ParameterTypeDefaultDescription
response_formatstringjsonResponse format. Use text to return only the enhanced prompt as plain text.

Example Requests

JSON (default)

curl -X POST "https://services.spaceprompts.com/api/v2/prompts/enhance" \
  -H "X-API-Key: {YOUR_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Convert this sentence to formal business English."}'

Example Response

200 OK
{
  "enhanced_prompt": "You are a professional business writing assistant. Rewrite the given sentence in formal business English, preserving the original meaning while using polite, professional, and concise language."
}

Response Status Codes

CodeDescription
200Successful response
401Missing or invalid API key
403API access requires a Pro or Team plan
404Prompt not found
429Rate limit exceeded — 60 requests/minute per API key