Skip to content

Getting Started with Octagon Agents API

Quick Start

1. Get an API Key

To use the Octagon Agents API, you'll need a free API key. You can get one by:

  1. Signing up for an Octagon account
  2. Go to the Settings page
  3. Navigate to the API Keys section
  4. Create a new API key

2. Make Your First API Call

Here's how to get comprehensive financial analysis using the market intelligence agent with different programming languages:

Python
from openai import OpenAI

client = OpenAI(
    # Note: Replace with your API key or use environment variables
    api_key="your-octagon-api-key",
    base_url="https://api-gateway.octagonagents.com/v1"
)

# Make the API call using the responses endpoint
response = client.responses.create(
    model="octagon-agent",
    instructions="You are a financial research market intelligence agent that intelligently routes queries to specialized agents.",
    input="Provide a comprehensive analysis of Apple's Q3 2023 financial performance including revenue, key metrics, and market insights."
)

# Extract and print the analysis text
analysis_text = response.output[0].content[0].text
print("ANALYSIS:")
print(analysis_text)

# Extract and print citations
annotations = response.output[0].content[0].annotations
print("\nSOURCES:")
for annotation in annotations:
    print(f"{annotation.order}. {annotation.name}: {annotation.url}")

# Example output:

# ANALYSIS:
# In the third quarter of 2023, Apple delivered strong financial performance with total net sales of $81,797 million, representing a comprehensive view across products ($60,584 million) and services ($21,213 million) [1], [2]. The market intelligence agent analyzed multiple data sources to provide this comprehensive financial overview.

# SOURCES:
# 1. Apple Inc. (10-Q) - 2023-Q3, Page: 10: https://octagon-sec-filings.s3.amazonaws.com/320193/0000320193-23-000077/aapl-20230701.pdf?response-content-disposition=inline&response-content-type=application%2Fpdf&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYGEZZN2EGRGVN56Y%2F20250401%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250401T220525Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=783c748f003e66bbdb61b2da4b49e3a31da0213617ff2237d1316da2885ca515#page=10
# 2. Apple Inc. (10-Q) - 2023-Q3, Page: 4: https://octagon-sec-filings.s3.amazonaws.com/320193/0000320193-23-000077/aapl-20230701.pdf?response-content-disposition=inline&response-content-type=application%2Fpdf&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYGEZZN2EGRGVN56Y%2F20250401%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250401T220525Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=783c748f003e66bbdb61b2da4b49e3a31da0213617ff2237d1316da2885ca515#page=4
JavaScript
import OpenAI from 'openai';

const client = new OpenAI({
  // Note: Replace with your API key or use environment variables
  apiKey: 'your-octagon-api-key',
  baseURL: 'https://api-gateway.octagonagents.com/v1'
});

async function getAnalysis() {
  // Make the API call using the responses endpoint
  const response = await client.responses.create({
    model: "octagon-agent",
    instructions: "You are a financial research market intelligence agent that intelligently routes queries to specialized agents.",
    input: "Provide a comprehensive analysis of Apple's Q3 2023 financial performance including revenue, key metrics, and market insights."
  });

  // Extract and print the analysis text
  const analysisText = response.output[0].content[0].text;
  console.log("ANALYSIS:");
  console.log(analysisText);

  // Extract and print citations
  const annotations = response.output[0].content[0].annotations;
  console.log("\nSOURCES:");
  annotations.forEach(annotation => {
    console.log(`${annotation.order}. ${annotation.name}: ${annotation.url}`);
  });
}

getAnalysis();

// Example output:

// ANALYSIS:
// In the third quarter of 2023, Apple delivered strong financial performance with total net sales of $81,797 million, representing a comprehensive view across products ($60,584 million) and services ($21,213 million) [1], [2]. The market intelligence agent analyzed multiple data sources to provide this comprehensive financial overview.

// SOURCES:
// 1. Apple Inc. (10-Q) - 2023-Q3, Page: 10: https://octagon-sec-filings.s3.amazonaws.com/320193/0000320193-23-000077/aapl-20230701.pdf?response-content-disposition=inline&response-content-type=application%2Fpdf&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYGEZZN2EGRGVN56Y%2F20250401%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250401T220525Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=783c748f003e66bbdb61b2da4b49e3a31da0213617ff2237d1316da2885ca515#page=10
// 2. Apple Inc. (10-Q) - 2023-Q3, Page: 4: https://octagon-sec-filings.s3.amazonaws.com/320193/0000320193-23-000077/aapl-20230701.pdf?response-content-disposition=inline&response-content-type=application%2Fpdf&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYGEZZN2EGRGVN56Y%2F20250401%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250401T220525Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=783c748f003e66bbdb61b2da4b49e3a31da0213617ff2237d1316da2885ca515#page=4
cURL
curl -X POST https://api-gateway.octagonagents.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-octagon-api-key" \
  -d '{
    "model": "octagon-agent",
    "instructions": "You are a financial research market intelligence agent that intelligently routes queries to specialized agents.",
    "input": "Provide a comprehensive analysis of Apple'\''s Q3 2023 financial performance including revenue, key metrics, and market insights."
  }'

Next Steps

Support

If you need help with the Octagon Agents API, you can: