DevUp Docs
Back to Dashboard

Integrations

LangChain

Use DEVUP AI models with LangChain's ChatOpenAI class for seamless Python AI workflows.

Because DEVUP AI exposes a fully OpenAI-compatible API, you can use it as a drop-in replacement in any LangChain pipeline. Point your openai_api_base to our gateway and access 142+ open-source models with zero code changes to your existing chains.

Prerequisites

  • A DEVUP AI account with a valid API key (Dashboard → API Keys).
  • Python 3.9 or later.
  • The langchain-openai package installed.

Installation

bash
pip install langchain-openai

Basic Usage

Pass your DEVUP API key and gateway URL to ChatOpenAI. All 142+ models available on the platform are accessible via the model_name parameter.

python
from langchain_openai import ChatOpenAI

# Initialize the DEVUP AI endpoint
chat = ChatOpenAI(
    openai_api_key="your-devup-api-key",
    openai_api_base="https://api.devupai.com/v1",
    model_name="deepseek-chat"  # or any of our 142+ models
)

response = chat.invoke("Hello, DEVUP AI!")
print(response.content)

Using Environment Variables

For production deployments, store your API key in an environment variable instead of hardcoding it:

bash
export DEVUP_API_KEY="sk-devup-your_key_here"
python
import os
from langchain_openai import ChatOpenAI

chat = ChatOpenAI(
    openai_api_key=os.environ["DEVUP_API_KEY"],
    openai_api_base="https://api.devupai.com/v1",
    model_name="deepseek-chat",
)

Streaming Responses

Enable streaming to receive tokens as they are generated. This is ideal for real-time UIs and long-form content generation:

python
from langchain_openai import ChatOpenAI

chat = ChatOpenAI(
    openai_api_key="your-devup-api-key",
    openai_api_base="https://api.devupai.com/v1",
    model_name="deepseek-chat",
    streaming=True,
)

for chunk in chat.stream("Explain quantum computing in 3 sentences."):
    print(chunk.content, end="", flush=True)

Building Chains with LCEL

DEVUP AI works seamlessly with LangChain Expression Language (LCEL). Compose prompts, models, and output parsers into production pipelines:

python
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate

chat = ChatOpenAI(
    openai_api_key="your-devup-api-key",
    openai_api_base="https://api.devupai.com/v1",
    model_name="deepseek-chat",
)

prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a senior {language} developer."),
    ("human", "{question}"),
])

chain = prompt | chat

response = chain.invoke({
    "language": "Python",
    "question": "What is the best way to handle async in Python 3.12?"
})

print(response.content)

Configuration Options

Fine-tune model behavior using standard OpenAI parameters:

python
chat = ChatOpenAI(
    openai_api_key="your-devup-api-key",
    openai_api_base="https://api.devupai.com/v1",
    model_name="deepseek-chat",
    temperature=0.2,         # Lower = more deterministic
    max_tokens=2048,         # Max completion length
    request_timeout=30,      # Timeout in seconds
)
ParameterTypeDescription
openai_api_basestrAlways https://api.devupai.com/v1
openai_api_keystrYour DEVUP AI API key (prefixed with sk-devup-).
model_namestrAny supported DevUp model alias or full model ID.
temperaturefloatSampling temperature (0.0–2.0). Default: 0.7.
max_tokensintMaximum number of completion tokens to generate.
streamingboolEnable token-by-token streaming. Default: False.

Notes

  • DEVUP AI is fully OpenAI-compatible — any LangChain component that uses ChatOpenAI or OpenAIEmbeddings works out of the box.
  • Tool calling, structured outputs, and function calling are supported on models that natively support them.
  • All requests are metered and billed in Algerian Dinar (DZD) via your account balance.
If you are migrating from OpenAI, the only change required is setting openai_api_base to https://api.devupai.com/v1 and swapping your API key. All existing chains, agents, and tools remain fully compatible.