Ctrl + K

API Reference

Integrate Blurs AI into your development tools and workflows using our API.

Authentication

All API requests require authentication using your Oblien API key:

Authorization: Bearer YOUR_API_KEY

Get your API key from the Oblien Dashboard.

Base URL

https://api.oblien.com/v1/blurs

Endpoints

Generate Code

Generate code based on a natural language description.

Endpoint: POST /generate

Request Body:

{
  "prompt": "Create a React component for a user profile card",
  "language": "typescript",
  "framework": "react",
  "context": "optional code context"
}

Response:

{
  "code": "generated code here",
  "explanation": "explanation of the generated code",
  "suggestions": ["optional improvements"]
}

Debug Code

Analyze and fix bugs in your code.

Endpoint: POST /debug

Request Body:

{
  "code": "code with bug",
  "error": "error message or description",
  "context": "additional context"
}

Response:

{
  "analysis": "analysis of the issue",
  "fix": "fixed code",
  "explanation": "explanation of the fix",
  "prevention": "tips to prevent similar issues"
}

Optimize Code

Get performance optimization suggestions.

Endpoint: POST /optimize

Request Body:

{
  "code": "code to optimize",
  "type": "performance|bundle|database",
  "metrics": {
    "current": "current metric value",
    "target": "target metric value"
  }
}

Response:

{
  "analysis": "performance analysis",
  "optimizations": [
    {
      "type": "optimization type",
      "code": "optimized code",
      "improvement": "expected improvement",
      "explanation": "why this helps"
    }
  ]
}

SDK Usage

JavaScript/TypeScript

import { BlursClient } from '@oblien/blurs-sdk';

const client = new BlursClient({
  apiKey: process.env.OBLIEN_API_KEY
});

// Generate code
const result = await client.generate({
  prompt: 'Create a React button component',
  language: 'typescript',
  framework: 'react'
});

// Debug code
const debug = await client.debug({
  code: codeWithBug,
  error: 'Error message'
});

// Optimize code
const optimized = await client.optimize({
  code: slowCode,
  type: 'performance'
});

Python

from oblien_blurs import BlursClient

client = BlursClient(api_key="your-api-key")

# Generate code
result = client.generate(
    prompt="Create a Python function to parse JSON",
    language="python"
)

# Debug code
debug = client.debug(
    code=buggy_code,
    error="Error message"
)

Rate Limits

  • Free tier: 100 requests per day
  • Pro tier: 1,000 requests per day
  • Enterprise: Custom limits

Rate limit headers:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1234567890

Error Handling

Error Response Format

{
  "error": {
    "code": "ERROR_CODE",
    "message": "Human readable error message",
    "details": {}
  }
}

Common Error Codes

  • INVALID_API_KEY - API key is invalid or missing
  • RATE_LIMIT_EXCEEDED - Too many requests
  • INVALID_REQUEST - Request format is invalid
  • GENERATION_FAILED - Code generation failed
  • QUOTA_EXCEEDED - Daily quota exceeded

Webhooks

Subscribe to events for async operations:

{
  "webhook_url": "https://your-app.com/webhooks/blurs",
  "events": ["generation.complete", "optimization.complete"]
}

Examples

Generate Component

curl -X POST https://api.oblien.com/v1/blurs/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Create a React TypeScript component for a todo item",
    "language": "typescript",
    "framework": "react"
  }'

Debug Error

curl -X POST https://api.oblien.com/v1/blurs/debug \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "function test() { return data.items.map(...) }",
    "error": "Cannot read property map of undefined"
  }'

Best Practices

  1. Cache Results - Generated code can be cached for identical requests
  2. Handle Errors - Always handle API errors gracefully
  3. Respect Rate Limits - Implement retry logic with backoff
  4. Validate Inputs - Validate user inputs before sending to API
  5. Review Generated Code - Always review and test generated code

Support