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.
2. Make Your First Request
Here's a simple example using curl to test your API connection:
Quick Test with curl
bashcurl 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
pythonimport 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
javascriptconst 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_KEYBest 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
gpt-4
More capable model for complex reasoning and analysis
Rate Limits
API requests are subject to rate limits based on your plan:
Next Steps
Now that you're set up, explore more advanced features: