Connect DSPy
Configure a Chat Completions language model with an exact service ID and a private credential.
https://aelder.dev/v1LOCAL 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.
Help me connect DSPy to AELDER using this guide: https://aelder.dev/docs/dspy/
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.DSPy can use a custom OpenAI-compatible endpoint for text generation. This recipe uses its LiteLLM compatibility engine and Chat Completions.
1. Prepare the environment
In your project’s Python environment:
python -m pip install dspySet 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 privately through your environment or secrets manager.
Check your installed DSPy version before modifying an existing project. The engine selector below is part of the current LM API; older releases may not expose it. Use the reference for your version rather than forwarding an unknown engine field to the model.
2. Configure the language model
import os
import dspy
lm = dspy.LM(
model="openai/" + os.environ["SERVICE_MODEL_ID"],
api_base=os.environ["SERVICE_BASE_URL"],
api_key=os.environ["SERVICE_API_KEY"],
model_type="chat",
engine="litellm",
num_retries=0,
cache=False,
)
replies = lm("Reply with OK.")
print(replies[0])The outer openai/ selects the adapter; everything after it is the exact service model ID, including any slash in that ID. Do not change the ID itself. Local response caching is disabled in this first-check example.
3. Check before running a program
Construct lm first without calling it to check imports and configuration. lm(...) sends a billable request. Verify its model and usage in your dashboard. Recreate lm with a different exact ID to switch models.
For your DSPy program, use dspy.configure(lm=lm) only when you intend to set that process’s default, or use dspy.context(lm=lm) for a limited scope. Preserve other project settings. Optimizers and evaluation runs may call the model many times; a working short text request does not establish support for tool calls, structured output, training or fine-tuning.
Sources: DSPy’s LM implementation and language-model guide.
Need the key? Open your AELDER dashboard. For direct API calls, see the API reference.

