AI Tools API Setup Guide

Configuration notes for programmatic access to AI services

Important Security Notice

Never commit API keys to version control. Use environment variables or secure secret management systems. Keep this information private and secure.

OpenAI API (ChatGPT)

Setup Steps

  1. 1. Create account at platform.openai.com
  2. 2. Navigate to API Keys section
  3. 3. Generate new API key
  4. 4. Set usage limits and billing

Python Example

import openai
import os
# Set API key from environment
openai.api_key = os.getenv("OPENAI_API_KEY")
# Make API call
response = openai.ChatCompletion.create(
model="gpt-4",
messages=[{"role": "user", "content": "Hello!"}]
)

Pricing (as of 2024)

  • • GPT-4: $0.03/1K input tokens, $0.06/1K output tokens
  • • GPT-3.5-turbo: $0.0005/1K input tokens, $0.0015/1K output tokens

Google AI API (Gemini)

Setup Steps

  1. 1. Visit Google AI Studio
  2. 2. Sign in with Google account
  3. 3. Create API key
  4. 4. Enable Gemini API

Python Example

import google.generativeai as genai
import os
# Configure API
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
# Create model
model = genai.GenerativeModel('gemini-pro')
response = model.generate_content("Hello!")
print(response.text)

Features

  • • Multimodal input (text, images, audio, video)
  • • Long context window (up to 1M tokens)
  • • Free tier available for testing

Perplexity API

Setup Steps

  1. 1. Sign up at perplexity.ai
  2. 2. Request API access (may require Pro subscription)
  3. 3. Generate API token

Python Example

import requests
import os
url = "https://api.perplexity.ai/chat/completions"
headers = {
"Authorization": f"Bearer {os.getenv('PERPLEXITY_API_KEY')}",
"Content-Type": "application/json"
}
data = {
"model": "pplx-7b-online",
"messages": [{"role": "user", "content": "Research query"}]
}
response = requests.post(url, json=data, headers=headers)

Use Cases

  • • Real-time web search with AI
  • • Citation-backed research
  • • Current events and news

NotebookLM

Note: NotebookLM currently operates as a web application without a public API. Access is through the web interface only.

Current Access

Workaround for Integration

  • • Upload documents manually via web UI
  • • Copy insights to other tools as needed
  • • Use as knowledge repository alongside programmatic tools

Environment Variables Setup

Create .env file

# .env file - DO NOT COMMIT TO GIT
OPENAI_API_KEY=sk-...
GOOGLE_API_KEY=AI...
PERPLEXITY_API_KEY=pplx-...

.gitignore entry

# .gitignore
.env
*.key
secrets/

Load in Python

from dotenv import load_dotenv
import os
load_dotenv()
api_key = os.getenv("OPENAI_API_KEY")

Best Practices

Security

  • • Never hardcode API keys
  • • Use environment variables
  • • Rotate keys regularly
  • • Set spending limits

Rate Limiting

  • • Implement exponential backoff
  • • Cache frequent queries
  • • Monitor usage quotas
  • • Handle errors gracefully