# AI Providers

Integrate AI providers like OpenAI, Claude, and Gemini to build smarter, modular workflows effortlessly.

Aivara empowers developers to integrate seamlessly with top **AI providers**, enabling everything from text generation and chat agents to automation workflows and real-time analysis. With Aivara’s modular architecture, you can connect these providers effortlessly, swap models in seconds, and unlock the full potential of modern AI.

***

**Supported Providers**

Aivara currently supports:

* **OpenAI** Use models like **GPT-3.5** and **GPT-4** for text generation, summarization, question-answering, and creative tasks.
* **Claude by Anthropic** Build conversational agents or reasoning workflows with **Claude v1** and **Claude v2** for natural dialogue and decision-making.
* **Gemini by Google** Integrate Google’s **multimodal AI** models to process text, vision, and structured data for more complex workflows.
* **Grok by xAI** Leverage Grok for **AI reasoning** and automation, especially in logic-driven tools.
* **Perplexity AI** Access real-time search, summarization, and data analysis tools with **Perplexity AI** to integrate up-to-date information.

***

**How** Aivara **Makes It Easy**

Aivara’s **Input, Processing, and Output Blocks** simplify connecting AI providers into your workflows. Each provider can be added in just a few lines of code, and switching between them is frictionless.

***

**Example 1: Text Generation with OpenAI GPT-4**

This example demonstrates a text summarization pipeline using OpenAI:

Copy

Copy

Copy

```
pythonCopy codefrom aivara import InputBlock, ProcessingBlock, OutputBlock  

# Input Block: Capture the text you want summarized  
input_block = InputBlock("user_input", prompt="Summarize the following: Aivara simplifies AI development workflows.")  

# Processing Block: Use OpenAI's GPT-4 API for text generation  
processing_block = ProcessingBlock("openai", model="gpt-4", api_key="YOUR_OPENAI_API_KEY")  

# Output Block: Send the AI response to the console  
output_block = OutputBlock("console")  

# Workflow: Connect the blocks and run the pipeline  
workflow = input_block >> processing_block >> output_block  
workflow.run()
```

***

**Example 2: Switching to Claude with Minimal Changes**

To use Anthropic’s Claude instead of OpenAI, simply change the provider in the **ProcessingBlock**:

Copy

Copy

Copy

```
pythonCopy code# Processing Block: Switch from OpenAI to Claude  
processing_block = ProcessingBlock("claude", model="claude-v2", api_key="YOUR_CLAUDE_API_KEY")
```

Everything else in your workflow remains intact. Aivara’s modular approach allows you to experiment and optimize without rewriting entire codebases.

***

**Example 3: Building a Chat Agent**

Here’s how you can create a chat agent that listens to input, generates responses using Gemini, and outputs back to a user interface:

Copy

Copy

Copy

```
pythonCopy codefrom aivara import InputBlock, ProcessingBlock, OutputBlock  

# Input Block: Capture user messages (e.g., from Discord or Console)  
input_block = InputBlock("discord", token="YOUR_DISCORD_TOKEN", channel_id="1234567890")  

# Processing Block: Use Google's Gemini API to process the message  
processing_block = ProcessingBlock("gemini", model="gemini-1", api_key="YOUR_GEMINI_API_KEY")  

# Output Block: Send the AI-generated response back to the channel  
output_block = OutputBlock("discord_response", token="YOUR_DISCORD_TOKEN")  

# Workflow: Chain the blocks together  
workflow = input_block >> processing_block >> output_block  
workflow.run()
```

***

**Example 4: Integrating Perplexity AI for Real-Time Search**

Combine real-time search capabilities from Perplexity AI with Aivara workflows:

Copy

Copy

Copy

```
pythonCopy codefrom aivara import InputBlock, ProcessingBlock, OutputBlock  

# Input Block: A search query provided by the user  
input_block = InputBlock("user_input", prompt="What is Aivara?")  

# Processing Block: Perplexity AI for real-time search and summarization  
processing_block = ProcessingBlock("perplexity", api_key="YOUR_PERPLEXITY_API_KEY")  

# Output Block: Print the results to the console  
output_block = OutputBlock("console")  

# Workflow: Link the blocks and execute  
workflow = input_block >> processing_block >> output_block  
workflow.run()
```

***

**Why Modular AI Providers Matter**

1. **Experimentation Made Easy** Test multiple providers (OpenAI, Claude, Gemini) within the same workflow to find the best solution for your task.
2. **Cost and Performance Optimization** Switch between providers depending on cost efficiency, performance needs, or API capabilities.
3. **Simplified Integration** With Aivara, complex provider APIs are abstracted into clean, reusable blocks, making it easy to focus on your logic rather than boilerplate code.

***

**Real-World Use Cases**

* **Content Generation**: Generate marketing copy, blog posts, or creative content using OpenAI or Claude.
* **Conversational AI**: Deploy chatbots and virtual assistants for Discord, Telegram, or web apps.
* **Automated Summarization**: Summarize long documents, research papers, or articles.
* **Knowledge Agents**: Combine Perplexity AI for real-time search with reasoning workflows powered by Grok.

***

**Conclusion**

Aivara’s AI Provider integrations give you the freedom to experiment, scale, and optimize your AI tools without friction. Whether you’re building real-time chat agents, automating content, or enhancing decision-making workflows, Aivara makes it easy to leverage the best AI models available today.
