> ## Documentation Index
> Fetch the complete documentation index at: https://docs.suada.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Backend SDKs Overview

> Official server-side SDKs for integrating Suada with your backend services

## Introduction

Suada provides official backend SDKs to help you integrate AI-powered chat and analysis capabilities into your server-side applications. Our SDKs are designed with developer experience in mind, offering type safety, comprehensive documentation, and intuitive APIs.

## Available SDKs

<CardGroup cols={2}>
  <Card title="Node.js SDK" icon="node-js" href="/sdks/node">
    Modern JavaScript/TypeScript SDK

    <ul className="mt-2">
      <li>Built-in TypeScript support</li>
      <li>Node.js 18+ compatibility</li>
      <li>LangChain integration</li>
    </ul>
  </Card>

  <Card title="Python SDK" icon="python" href="/sdks/python">
    Pythonic SDK with async support

    <ul className="mt-2">
      <li>Python 3.8+ support</li>
      <li>Pydantic type validation</li>
      <li>LangChain integration</li>
    </ul>
  </Card>
</CardGroup>

## Core Features

### 🔐 Authentication & Security

Both SDKs support secure authentication using API keys and include privacy features:

<CodeGroup>
  ```typescript Node.js theme={null}
  import { Suada } from '@suada/node';

  const suada = new Suada({
    apiKey: process.env.SUADA_API_KEY,
    privacyMode: true  // Optional enhanced security
  });
  ```

  ```python Python theme={null}
  from suada import Suada, SuadaConfig

  suada = Suada(
      config=SuadaConfig(
          api_key=os.getenv("SUADA_API_KEY"),
          privacy_mode=True  # Optional enhanced security
      )
  )
  ```
</CodeGroup>

### 🤖 LangChain Integration

Both SDKs provide seamless integration with LangChain for advanced AI capabilities:

<CodeGroup>
  ```typescript Node.js theme={null}
  import { Suada } from '@suada/node';
  import { AgentExecutor, createOpenAIFunctionsAgent } from 'langchain/agents';
  import { ChatOpenAI } from 'langchain/chat_models/openai';

  const suada = new Suada({
    apiKey: process.env.SUADA_API_KEY
  });

  const suadaTool = suada.createTool({
    name: 'business_analyst',
    description: 'Use this tool for business insights'
  });

  const agent = await createOpenAIFunctionsAgent({
    llm: new ChatOpenAI({ temperature: 0 }),
    tools: [suadaTool]
  });

  const executor = AgentExecutor.fromAgentAndTools({
    agent,
    tools: [suadaTool]
  });
  ```

  ```python Python theme={null}
  from suada import Suada, SuadaConfig
  from langchain.agents import AgentExecutor, create_openai_functions_agent
  from langchain.chat_models import ChatOpenAI
  from langchain.memory import ConversationBufferMemory

  suada = Suada(
      config=SuadaConfig(
          api_key="your-api-key"
      )
  )

  suada_tool = suada.create_tool(
      name="business_analyst",
      description="Use this tool for business insights"
  )

  agent = create_openai_functions_agent(
      llm=ChatOpenAI(temperature=0),
      tools=[suada_tool]
  )

  memory = ConversationBufferMemory(
      memory_key="chat_history",
      return_messages=True
  )

  executor = AgentExecutor.from_agent_and_tools(
      agent=agent,
      tools=[suada_tool],
      memory=memory
  )
  ```
</CodeGroup>

### 💬 Chat Interface

The chat endpoint is the primary way to interact with Suada. Both SDKs provide a consistent response format:

```typescript theme={null}
interface SuadaResponse {
    // Main response text
    answer: string;
    
    // Optional fields
    thoughts?: string;
    actions?: Array<{
        tool: string;
        toolInput: string;
        log: string;
    }>;
    followUpQuestion?: string;
    reasoning?: string;
    sources?: string[];
    conversationId?: string;
    timestamp: number;
}
```

### 👤 User Context Management

Both SDKs support passthrough mode for integrating with your application's user system:

<CodeGroup>
  ```typescript Node.js theme={null}
  const suada = new Suada({
    apiKey: process.env.SUADA_API_KEY,
    passthroughMode: true
  });

  const response = await suada.chat({
    message: "What's our performance?",
    externalUserIdentifier: "user-123"
  });
  ```

  ```python Python theme={null}
  suada = Suada(
      config=SuadaConfig(
          api_key=os.getenv("SUADA_API_KEY"),
          passthrough_mode=True
      )
  )

  response = suada.chat(
      message="What's our performance?",
      external_user_identifier="user-123"
  )
  ```
</CodeGroup>

## Key Benefits

### Type Safety

* Built-in TypeScript definitions (Node.js)
* Pydantic model validation (Python)
* IDE autocompletion support
* Runtime type checking

### LangChain Support

* Tool creation for LangChain agents
* Memory management for conversations
* Custom agent configurations
* Structured prompt templates

### Error Handling

* Structured error types
* Detailed error messages
* Automatic retry mechanisms
* Rate limit handling

### Performance

* Connection pooling
* Automatic retries
* Concurrent request support
* Efficient resource management

### Security

* Secure API key handling
* Privacy mode option
* User isolation in passthrough mode
* Rate limiting protection

## Getting Started

1. **Choose Your SDK**
   * Node.js: Modern JavaScript/TypeScript applications and web backends
   * Python: Data science, AI/ML, or Python web applications

2. **Installation**
   ```bash theme={null}
   # Node.js
   npm install @suada/node langchain

   # Python
   pip install suada langchain
   ```

3. **Configure Environment**
   ```bash theme={null}
   # .env file
   SUADA_API_KEY=your-api-key
   OPENAI_API_KEY=your-openai-key  # Required for LangChain integration
   ```

4. **Initialize Client**
   * Follow SDK-specific initialization
   * Configure optional features
   * Set up error handling
   * Initialize LangChain tools if needed

5. **Make Your First Request**
   * Send a test message
   * Handle the response
   * Implement error handling

## Best Practices

### Security

* Store API keys in environment variables
* Enable privacy mode for sensitive data
* Implement proper error handling
* Use secure user identification

### LangChain Integration

* Use clear tool descriptions
* Implement proper memory management
* Handle agent errors gracefully
* Monitor agent performance

### Performance

* Reuse SDK and agent instances
* Implement appropriate timeouts
* Handle rate limits gracefully
* Use async/await where available

### Development

* Use type checking tools
* Write comprehensive tests
* Follow SDK-specific conventions
* Keep dependencies updated

## FAQ

### Which SDK should I choose?

* Choose Node.js for JavaScript/TypeScript applications and modern web backends
* Choose Python for data science, AI/ML applications, or Python web services

### How do I handle rate limits?

Both SDKs implement automatic exponential backoff. You can customize retry behavior through configuration options.

### Can I use the SDKs in serverless environments?

Yes, both SDKs are compatible with serverless environments like AWS Lambda, Google Cloud Functions, and Vercel.

### How do I debug SDK issues?

Both SDKs provide detailed logging options:

* Node.js: Debug environment variable
* Python: Standard logging module

### Is local development supported?

Yes, both SDKs support local development with:

* Custom base URLs
* Debug logging
* Test environments
* Mock responses

## Support & Resources

### Documentation

* [Node.js SDK Documentation](/sdks/node)
* [Python SDK Documentation](/sdks/python)
* [LangChain Documentation](https://js.langchain.com/docs) (JavaScript)
* [LangChain Documentation](https://python.langchain.com/docs) (Python)

### Support

* Email: [support@suada.ai](mailto:support@suada.ai)
