AELDER

OpenAI SDK custom base URL: Python & JavaScript

Connect the Python or JavaScript OpenAI SDK to AELDER. Set base_url or baseURL, choose a model, compare API rates and send a text request.

AELDER · SERVICE BASE URL
https://aelder.dev/v1

LOCAL CONFIGURATION

Let my agent set this up

Copy this task to an agent already running on your computer. Enter your API key locally when asked.

SETUP PROMPT
Help me connect OpenAI SDK to AELDER using this guide: https://aelder.dev/docs/openai-sdk/
Service Base URL: https://aelder.dev/v1
First inspect my installed version, active profile and configuration. Explain any mismatch with the guide before changing anything.
Use the documented local configuration or CLI method. Do not automate the GUI, install software or change permissions without asking.
Preserve existing accounts, providers, models, defaults, permissions and unrelated settings. Propose the smallest change, show a redacted diff, and back up any files before editing.
Have me enter my API key locally using the tool's secret storage or an environment variable. Never ask me to paste a key into chat, print it, or include it in a command, diff, log or commit.
Use the exact model ID I choose from my account's model list. Do not invent model IDs or assume every model supports every API format or tool feature.
Validate syntax and configuration loading before making any generation request. If there is no dry-run, say so.
Explain any proposed paid test, the model and what it sends, and ask for approval before running it. Do not send project files or private conversation history as a test.
Finish with the settings changed, checks performed and steps to restore the backup.

Use the OpenAI SDK with a custom base URL to connect Python or JavaScript code to AELDER. Authenticate with your AELDER API key. This is an OpenAI-compatible API connection; an OpenAI account or ChatGPT subscription does not supply this service key.

SDK Base URL option API key option
Python base_url api_key
JavaScript / TypeScript baseURL apiKey

1. Prepare your project

Choose a catalog model before configuring its request ID: compare Claude model versions and API prices or DeepSeek model versions and token rates. The SDK connection format does not establish support for every optional model feature.

In your project’s environment, set SERVICE_BASE_URL to the Base URL above, including /v1, and SERVICE_MODEL_ID to an exact ID from your model list. Provide SERVICE_API_KEY through your local secrets manager or private environment. Do not put it in browser code or commit it.

Install the SDK in your existing virtual environment or Node.js project:

python -m pip install openai

For JavaScript, use npm install openai instead. The following examples explicitly use Chat Completions.

2. Make a text request

Python: set base_url

import os
from openai import OpenAI

client = OpenAI(
    base_url=os.environ["SERVICE_BASE_URL"],
    api_key=os.environ["SERVICE_API_KEY"],
    max_retries=0,
)
response = client.chat.completions.create(
    model=os.environ["SERVICE_MODEL_ID"],
    messages=[{"role": "user", "content": "Reply with OK."}],
)
print(response.choices[0].message.content)

JavaScript: set baseURL

Save this as an ES module such as example.mjs:

import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: process.env.SERVICE_BASE_URL,
  apiKey: process.env.SERVICE_API_KEY,
  maxRetries: 0,
});
const response = await client.chat.completions.create({
  model: process.env.SERVICE_MODEL_ID,
  messages: [{ role: 'user', content: 'Reply with OK.' }],
});
console.log(response.choices[0].message.content);

Each example sends a billable generation request. To inspect available IDs first, use client.models.list() in either SDK; listing models is not a generation test. Use a different exact ID in SERVICE_MODEL_ID to switch models.

3. Check the format and result

Keep /v1 in the SDK base URL and leave /chat/completions out; the SDK adds that path. Verify the request in your dashboard. For streaming and Responses examples, see the API reference. Use responses.create only with a model that supports that format.

An SDK also exposes files, embeddings, images, audio and other APIs. Their presence in the library does not establish support in this text API. Automatic retry is disabled in these first-check examples; add a bounded retry policy deliberately for your application.

Model selection and API costs

Review model token prices, then use an exact ID from your account’s model list. The SDK package does not set AELDER’s token rates. Input and output usage determine the request cost; the API cost calculator can help estimate a workload. A successful model-list response verifies access to that list, not generation or billing behavior.

Troubleshoot the custom endpoint

  • 401: confirm that SERVICE_API_KEY is set in the process running the script and belongs to AELDER.
  • 404: use the service Base URL with /v1, without /chat/completions; the SDK appends the request path.
  • Model not found: copy the account model ID exactly, including any slashes. The display name is not necessarily the API ID.
  • 429: inspect the returned error before retrying. Repeated immediate retries can make a rate-limit problem worse; they do not fix an account or balance restriction.

Sources: official Python SDK and JavaScript SDK.

Need the key? Open your AELDER dashboard. For direct API calls, see the API reference.