Appearance
Authentication for Octagon Agents API
To use the Octagon Agents API, you need to include your API key with every request. This guide explains how to authenticate your requests to access Octagon's Agents.
1. Generating Your API Key
All requests to the Octagon AI Agents API require an API key for authentication. To get started, you'll need to sign up for an account at Octagon. After creating your account, navigate to Settings → API Keys to generate your API key that you can use to access our agents.
Your API key carries many privileges, including access to premium data sources and specialized investment research models. Keep it secure and never share it in publicly accessible areas like GitHub, client-side code, or public forums.
2. Using Your API Key
Authentication with OpenAI SDK
The recommended method for authenticating with the Octagon AI Agents API is to use the OpenAI SDK and provide your API key directly to the SDK client. This approach simplifies authentication and helps you get started quickly.
Python
from openai import OpenAI
# Initialize the OpenAI client with your Octagon API key
client = OpenAI(
api_key="YOUR_API_KEY", # Use environment variable in production
base_url="https://api.octagonagents.com/v1"
)
JavaScript
import OpenAI from 'openai';
// Initialize the OpenAI client with your Octagon API key
const client = new OpenAI({
apiKey: process.env.OCTAGON_API_KEY, // Use environment variable
baseURL: 'https://api.octagonagents.com/v1',
});
cURL
curl https://api.octagonagents.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "octagon-sec-agent",
"messages": [
{
"role": "user",
"content": "What is Apple's revenue growth rate over the past 3 years based on their SEC filings?"
}
],
"stream": true
}'
Next Steps
Now that you understand how to authenticate with the Octagon API, you can: