Skip to main content

Get Your Adaptive API Key

Sign up here to create an account and generate your API key.

Quick Setup

Installation

pip install langchain langchain-openai

Basic Usage

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    api_key="your-adaptive-api-key",
    base_url="https://api.llmadaptive.uk/v1",
    model="" # Empty string enables intelligent routing
)

response = llm.invoke("Explain machine learning simply")
print(response.content)

Streaming Example

for chunk in llm.stream("Tell me a story about AI"):
    print(chunk.content, end="", flush=True)

Key Features

  • Drop-in replacement - Works with existing LangChain code
  • Intelligent routing - Automatic model selection based on complexity
  • Streaming support - Real-time responses work seamlessly
  • Chain compatibility - All LangChain patterns work without changes

Next Steps