ShadAI Framework
  1. getting-started
ShadAI Framework
  • Index
  • README
  • Pricing
    • Pricing Plan
  • advanced
    • Best Practices
    • Tool Orchestration
    • Performance Optimization
    • Custom Tools
  • examples
    • Advanced Patterns
    • Custom Agent Examples
    • Market Research Examples
    • Multi-Document Analysis
    • Basic Query Examples
  • api-reference
    • Exceptions Reference
    • Engine Tool API
    • Shadai Client API Reference
    • Query Tool API
    • Summarize Tool API
    • Agent Tool API
    • Web Search Tool API
  • use-cases
    • Knowledge Synthesis
    • Research Assistant
    • Custom Workflows
    • Document Q&A
  • core-concepts
    • Architecture
    • Intelligent Agent
    • RAG System
    • Tools Overview
  • guides
    • Memory & Context
    • Streaming Responses
    • File Ingestion
    • Error Handling
    • Session Management
  • getting-started
    • Authentication
    • Your First Query
    • Quick Start
    • Installation
  1. getting-started

Authentication

Shadai uses API keys for secure authentication. This guide will help you set up your credentials.

Getting Your API Key#

1.
Log in to your Shadai web application
2.
Navigate to API Keys page (accessible from your sidebar)
3.
Click Create New Key
4.
Give your key a descriptive name
5.
Copy your API key immediately (you'll only see it once!)

Configuration Methods#

Method 1: Environment Variables (Recommended)#

Create a .env file in your project root:
Load it in your code:

Method 2: Direct Initialization#

Pass the API key directly (not recommended for production):

Method 3: Context Manager with API Key#

Environment Variables Reference#

VariableDescriptionDefaultRequired
SHADAI_API_KEYYour API key-✅
SHADAI_BASE_URLAPI base URLhttp://localhost❌
SHADAI_TIMEOUTRequest timeout (seconds)30❌

Security Best Practices#

✅ Do This#

Store API keys in .env files
Add .env to .gitignore
Use different keys for dev/staging/production
Rotate keys regularly
Use environment-specific secrets management (AWS Secrets Manager, etc.)

❌ Don't Do This#

Hard-code API keys in source code
Commit API keys to version control
Share API keys via email or chat
Use the same key across all environments
Store keys in plain text files

Example .gitignore#

# Environment variables
.env
.env.local
.env.*.local

# API keys
*_api_key*
secrets/

Testing Authentication#

Verify your authentication is working:
Expected output:
✅ Authentication successful! Status: ok

Error Handling#

Invalid API Key#

Missing API Key#

Multiple Accounts#

Working with multiple Shadai accounts:

Custom Base URL#

For self-hosted or enterprise deployments:

Next Steps#

✅ Authentication configured! Let's run your first query.
→ Quick Start Guide
Modified at 2025-10-17 17:48:00
Previous
Session Management
Next
Your First Query
Built with