DEVUP Docs
Back to Dashboard

Integrations

Python

Connect Python applications to DEVUP AI using the official OpenAI and Anthropic SDKs. Access our unified platform with sync and async clients, robust timeout and retry configurations, Anthropic Messages streaming, and structured error handling.

Prerequisites

Installation

Install the official OpenAI and Anthropic client libraries from PyPI:

bash
pip install openai anthropic

Set your API key

Export your DEVUP AI API key in your environment so the clients can read it automatically:

export DEVUP_API_KEY="your-api-key"

OpenAI client

Initialize the synchronous OpenAI client pointed to https://api.devupai.com/v1:

python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.devupai.com/v1",
    api_key=os.environ["DEVUP_API_KEY"],
)

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Pro",
    messages=[{"role": "user", "content": "Say hello in one word."}],
)

print(response.choices[0].message.content)

For streaming, tool calling, structured outputs, embeddings, and model listings with OpenAI, see the OpenAI SDK guide.

Async client

Use AsyncOpenAI with Python's asyncio to handle multiple requests concurrently:

python
import asyncio
import os
from openai import AsyncOpenAI

client = AsyncOpenAI(
    base_url="https://api.devupai.com/v1",
    api_key=os.environ["DEVUP_API_KEY"],
)

async def main():
    tasks = [
        client.chat.completions.create(
            model="deepseek-ai/DeepSeek-V4-Pro",
            messages=[{"role": "user", "content": "Say 'alpha' in one word."}],
        ),
        client.chat.completions.create(
            model="deepseek-ai/DeepSeek-V4-Pro",
            messages=[{"role": "user", "content": "Say 'beta' in one word."}],
        ),
    ]
    responses = await asyncio.gather(*tasks)
    print("Reply 1:", responses[0].choices[0].message.content)
    print("Reply 2:", responses[1].choices[0].message.content)

asyncio.run(main())

Timeouts and retries

Configure per-client network timeouts and automatic retry attempts for resilient production deployments:

python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.devupai.com/v1",
    api_key=os.environ["DEVUP_API_KEY"],
    timeout=30.0,
    max_retries=2,
)

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Pro",
    messages=[{"role": "user", "content": "Say hello in one word."}],
)

print(response.choices[0].message.content)

Anthropic SDK

Connect the official Anthropic client to DEVUP AI by setting the base URL to https://api.devupai.com/anthropic:

python
import os
import anthropic

client = anthropic.Anthropic(
    base_url="https://api.devupai.com/anthropic",
    api_key=os.environ["DEVUP_API_KEY"],
)

message = client.messages.create(
    model="deepseek-ai/DeepSeek-V4-Pro",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Say hello in one word."}],
)

print(message.content[0].text)

For more Anthropic Messages API examples, see the Anthropic SDK & Claude guide.

Anthropic streaming

Stream tokens in real time from the Messages API using client.messages.stream:

python
import os
import anthropic

client = anthropic.Anthropic(
    base_url="https://api.devupai.com/anthropic",
    api_key=os.environ["DEVUP_API_KEY"],
)

with client.messages.stream(
    model="deepseek-ai/DeepSeek-V4-Pro",
    max_tokens=50,
    messages=[{"role": "user", "content": "Count from 1 to 5."}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
print()

Frameworks

For agent workflows and chain-based LLM architectures in Python, integrate DEVUP AI models directly with LangChain using standard OpenAI-compatible endpoints.

For multi-agent orchestration, configure AutoGen agents to run on DEVUP AI inference with full conversational routing support.

Error handling

Catch SDK authentication and status errors explicitly from both client libraries:

python
import os
import openai
import anthropic

client_openai = openai.OpenAI(
    base_url="https://api.devupai.com/v1",
    api_key=os.environ["DEVUP_API_KEY"],
)

try:
    client_openai.chat.completions.create(
        model="deepseek-ai/DeepSeek-V4-Pro",
        messages=[{"role": "user", "content": "Hi"}],
    )
except openai.AuthenticationError as e:
    print(f"OpenAI: {type(e).__name__} {e.status_code}")

client_anthropic = anthropic.Anthropic(
    base_url="https://api.devupai.com/anthropic",
    api_key=os.environ["DEVUP_API_KEY"],
)

try:
    client_anthropic.messages.create(
        model="deepseek-ai/DeepSeek-V4-Pro",
        max_tokens=16,
        messages=[{"role": "user", "content": "Hi"}],
    )
except anthropic.AuthenticationError as e:
    print(f"Anthropic: {type(e).__name__} {e.status_code}")

For error classifications and status codes, see the Error handling guide.