Overview
LangChain is a popular framework for developing applications powered by language models. RedPill’s OpenAI-compatible API works seamlessly with LangChain.All requests through LangChain automatically flow through RedPill’s TEE-protected gateway.
Installation
Python Integration
Basic Setup
Streaming Responses
Using Multiple Models
RedPill supports 218+ models. Switch between them easily:Conversation Chains
TypeScript/JavaScript Integration
Basic Setup
Streaming in TypeScript
RAG (Retrieval Augmented Generation)
Function Calling with LangChain
Environment Variables
Store your API key securely:.env
Python
Supported Models
All 218+ RedPill models work with LangChain:Provider | Example Models |
---|---|
OpenAI | openai/gpt-4o , openai/gpt-4-turbo |
Anthropic | anthropic/claude-3.5-sonnet , anthropic/claude-sonnet-4 |
google/gemini-2.0-flash | |
DeepSeek | deepseek/deepseek-chat |
Phala (TEE) | phala/qwen-2.5-7b-instruct , phala/deepseek-chat-v3-0324 |
View All Models
Browse complete model list →
Best Practices
Use Environment Variables
Use Environment Variables
Never hardcode API keys. Use environment variables or secret managers.
Choose the Right Model
Choose the Right Model
- GPT-4o: Best for general tasks
- Claude 3.5 Sonnet: Best for reasoning and analysis
- DeepSeek: Best for coding tasks
- Phala models: Best for sensitive data (full TEE protection)
Enable Streaming for UX
Enable Streaming for UX
Use streaming for better user experience in interactive applications.
Implement Error Handling
Implement Error Handling
Wrap API calls in try-catch blocks to handle rate limits and errors gracefully.
Example Projects
Chatbot
Build a multi-turn conversational AI with memory
RAG System
Create a document Q&A system with embeddings
AI Agent
Build an autonomous agent with function calling
Content Generator
Generate articles, summaries, and creative content