Getting Started

Get up and running with the BrainTwin.ai API in just a few minutes.

OpenAI Compatible: BrainTwin.ai is fully compatible with OpenAI's API. Simply change the base URL and use your BrainTwin.ai API key.

1. Get Your API Key

First, you'll need to sign up for BrainTwin.ai and get your API key from the dashboard.

Keep your API key secure and never expose it in client-side code. Use environment variables or secure storage.

2. Make Your First Request

Here's a simple example using curl to test your API connection:

Quick Test with curl

bash
curl https://inference.braintwin.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-3.5-turbo",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

3. Use with Popular SDKs

BrainTwin.ai works with existing OpenAI SDKs. Just change the base URL:

Python (OpenAI SDK)

Python Example

python
import openai

# Set your API key and base URL
openai.api_key = "YOUR_API_KEY"
openai.api_base = "https://inference.braintwin.ai/v1"

# Make a completion request
response = openai.ChatCompletion.create(
  model="gpt-3.5-turbo",
  messages=[
    {"role": "user", "content": "Hello! How are you?"}
  ]
)

print(response.choices[0].message.content)

JavaScript/Node.js

JavaScript Example

javascript
const response = await fetch('https://inference.braintwin.ai/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify({
    model: 'gpt-3.5-turbo',
    messages: [
      { role: 'user', content: 'Hello! How are you?' }
    ]
  })
});

const data = await response.json();
console.log(data.choices[0].message.content);

Authentication

All API requests must include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Best Practices:

  • Store API keys as environment variables
  • Never commit API keys to version control
  • Use different keys for development and production
  • Rotate keys regularly for enhanced security

Supported Models

BrainTwin.ai supports various AI models for different use cases:

gpt-3.5-turbo

Fast, efficient model for most conversational tasks

Best for: Chat, Q&A, General tasks

gpt-4

More capable model for complex reasoning and analysis

Best for: Complex tasks, Analysis, Code

Rate Limits

API requests are subject to rate limits based on your plan:

Free Tier:
1,000 requests/month
Pro Tier:
100,000 requests/month