DEVUP Docs
Back to Dashboard

Integrations

OpenAI SDK

Connect the official OpenAI client libraries directly to DEVUP AI. Our gateway exposes a wire-compatible endpoint supporting chat completions, streaming, tool calling, structured outputs, embeddings, and model listings.

Prerequisites

  • A DEVUP AI account with a valid API key (Dashboard → API Keys).
  • Python 3.10 or later or Node.js 22.0.0 or later.

Installation

pip install openai

Configure the client

Point the client base URL to DEVUP AI and supply your API key through an environment variable.

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.devupai.com/v1",
    api_key=os.environ["DEVUP_API_KEY"],
)
SettingValueDescription
Base URLhttps://api.devupai.com/v1DEVUP AI OpenAI-compatible gateway
API KeyDEVUP_API_KEYYour secret key starting with sk-devup-
Modeldeepseek-ai/DeepSeek-V4-ProAny active model ID from the catalog

Chat completions

Create standard chat completions by specifying the model ID and message list.

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)

Streaming

Stream tokens in real time with usage statistics. Learn more in Streaming documentation.

import os
from openai import OpenAI

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

stream = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Pro",
    messages=[{"role": "user", "content": "Count from 1 to 3."}],
    stream=True,
    stream_options={"include_usage": True},
)

final_usage = None
for chunk in stream:
    if chunk.usage is not None:
        final_usage = chunk.usage
    if not chunk.choices:
        continue
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)

print()
if final_usage:
    print("Tokens:", final_usage.total_tokens)

Tool calling

Execute client-side function calling with models supporting tools. See the complete reference in Tool Calling documentation.

import os
import json
from openai import OpenAI

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

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get current temperature for a city.",
            "parameters": {
                "type": "object",
                "properties": {
                    "city": {"type": "string"},
                },
                "required": ["city"],
            },
        },
    }
]

messages = [{"role": "user", "content": "What is the weather in Algiers?"}]

call1 = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Pro",
    messages=messages,
    tools=tools,
)

tool_call = call1.choices[0].message.tool_calls[0]
print("Tool called:", tool_call.function.name)
print("Arguments:", tool_call.function.arguments)

messages.append(call1.choices[0].message)
messages.append({
    "role": "tool",
    "tool_call_id": tool_call.id,
    "content": json.dumps({"city": "Algiers", "temperature": "22C"}),
})

call2 = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Pro",
    messages=messages,
)

print("Answer:", call2.choices[0].message.content)

Structured outputs

Enforce strict JSON schemas on generation results. Details are covered in Structured Outputs documentation.

import os
import json
from openai import OpenAI

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

schema = {
    "type": "object",
    "properties": {
        "capital": {"type": "string"},
        "country": {"type": "string"},
    },
    "required": ["capital", "country"],
    "additionalProperties": False,
}

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Pro",
    messages=[{"role": "user", "content": "What is the capital of Algeria?"}],
    response_format={
        "type": "json_schema",
        "json_schema": {
            "name": "capital_response",
            "strict": True,
            "schema": schema,
        },
    },
)

data = json.loads(response.choices[0].message.content)
print(json.dumps(data))

Embeddings

Generate dense vector embeddings using specialized models like BAAI/bge-m3. See Embeddings documentation.

import os
from openai import OpenAI

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

response = client.embeddings.create(
    model="BAAI/bge-m3",
    input=["First text string", "Second text string"],
)

print("Vectors:", len(response.data))
print("Dimensions:", len(response.data[0].embedding))

List models

Discover all available models and their capabilities. Browse full details in Models documentation.

import os
from openai import OpenAI

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

models = client.models.list()
has_v4_pro = any(m.id == "deepseek-ai/DeepSeek-V4-Pro" for m in models.data)

print("Count:", len(models.data))
print("V4-Pro:", has_v4_pro)

Error handling

Catch SDK authentication and status errors. Refer to Error Reference and Rate Limits.

import os
from openai import OpenAI, AuthenticationError, APIStatusError

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

try:
    client.chat.completions.create(
        model="deepseek-ai/DeepSeek-V4-Pro",
        messages=[{"role": "user", "content": "Hello"}],
    )
except AuthenticationError as e:
    print(e.__class__.__name__, e.status_code)
except APIStatusError as e:
    print(e.__class__.__name__, e.status_code)

Migrating from OpenAI

  • Change your client base URL to https://api.devupai.com/v1.
  • Supply your DEVUP AI API key starting with sk-devup-.
  • Select a supported model ID from the catalog, such as deepseek-ai/DeepSeek-V4-Pro.