Connect PydanticAI
Configure an explicit OpenAIChatModel with your custom endpoint and a locally supplied 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 PydanticAI to AELDER using this guide: https://aelder.dev/docs/pydantic-ai/
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.PydanticAI can use a custom OpenAI-compatible client. Select OpenAIChatModel explicitly for Chat Completions; a generic OpenAI model shorthand can default to Responses in current releases.
1. Prepare the environment
In your project virtual environment:
python -m pip install pydantic-aiSet SERVICE_BASE_URL to the Base URL above, including /v1, and SERVICE_MODEL_ID to an exact model ID. Make SERVICE_API_KEY available privately to the Python process through your environment or secrets manager.
2. Create the model and agent
import os
from openai import AsyncOpenAI
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.openai import OpenAIProvider
client = AsyncOpenAI(
base_url=os.environ["SERVICE_BASE_URL"],
api_key=os.environ["SERVICE_API_KEY"],
max_retries=0,
)
model = OpenAIChatModel(
os.environ["SERVICE_MODEL_ID"],
provider=OpenAIProvider(openai_client=client),
)
agent = Agent(model)
result = agent.run_sync("Reply with OK.")
print(result.output)This standalone script uses plain text output. In an existing async application, use await agent.run(...) instead of run_sync. Change the exact model ID and recreate the model to switch it.
3. Check a small request first
Importing and constructing these objects is a local check. run_sync sends a billable request; an agent with tools, validation retries or multiple turns can make several requests. Inspect the dashboard before moving to a larger workflow.
Structured output and tool use require support from the selected model and format. Start with text, then test each required feature. Check your installed PydanticAI version before updating older code that uses OpenAIModel; keep unrelated agent settings and tools intact.
Sources: PydanticAI’s OpenAI models and custom client and agent API.
Need the key? Open your AELDER dashboard. For direct API calls, see the API reference.

