Integrating Open-Source LLMs with Agents: Configuration Steps and Troubleshooting Guide
This article explains how to connect an open-source agent tool to a cloud LLM platform and how to troubleshoot common integration errors. It covers pre-configuration checks, API key handling, provider registration, default model setup, and the distinction between configuration mistakes and multi-turn message-order conflicts.
This article uses an open-source agent tool connecting to a cloud provider’s LLM platform as an example to explain the complete integration and troubleshooting workflow.
Open-source LLMs have made progress in reasoning, long-context handling, and coding capabilities, and more agent tools are beginning to support integration with these models. After integration, developers often encounter two types of problems: configuration errors that prevent calls from working, or errors such as “message order conflict” in multi-turn conversations.
This article only discusses integration methods and troubleshooting approaches. Cost and capability should be evaluated according to the following criteria: the cost of a single call depends on platform pricing and your own call volume, so it must be measured in practice; context window and reasoning capability should be based on the model’s official documentation, not just promotional numbers; call-volume rankings change over time, so this article does not cite rankings—consult the platform’s public statistical documentation to assess market position.
Platform names, model IDs, Base URL, and configuration file paths in this article are placeholders. Replace them with the real values in your own environment. The examples do not constitute official certification or performance commitments for any platform.
1. Pre-Configuration Checks
Before starting configuration, confirm the following information.
- The version number of the agent tool, and read the notes about model provider configuration in the changelog.
- The cloud platform plan that has been activated, and whether that plan includes the selected model.
- The model ID, copied from the platform’s model list page—do not write it by hand from memory.
- The API protocol type provided by the platform, for example whether it is compatible with the OpenAI Chat Completions format.
- Network connectivity. Run the following command on the machine running the agent. If it returns HTTP response headers, the domain is reachable.
curl -I "<domain part of the cloud platform Base URL>"
If the corporate intranet requires a proxy, set the proxy in the terminal first, then repeat the command above.
- Whether the API Key has permission to call the target model.
2. Credentials and Provider Configuration
2.1 Obtain and Save the API Key
On the cloud platform’s inference service page, activate the plan and select the target model, then generate a key on the API Key management page. The API Key is the access credential for quota; if leaked, others can directly consume your quota. Therefore, pay attention to the following points.
- Do not write the key into a configuration file and commit it to a code repository.
- Store the key in an environment variable or secret management service, for example:
export CLOUD_API_KEY="<API Key generated on the platform>"
- Avoid printing the key in scripts, command-line arguments, or logs.
echoandset -xcan both write the key into terminal history or log files. - Rotate keys regularly and grant only the permission required to call the target model.
- If a key leak is suspected, revoke the key on the platform immediately, regenerate it, update the environment variable, and check the platform’s call audit records.
2.2 Write the Provider Configuration
When registering the cloud platform provider in the agent tool, you need to fill in the Base URL, API Key, model ID, and model parameters. The following uses the openclaw command as an example. Content in angle brackets in the template must be replaced; do not execute it before replacement.
openclaw config set 'models.providers.cloud_provider' --json '{"baseUrl": "<Base URL provided by the cloud platform>","apiKey": "${CLOUD_API_KEY}","api": "openai-completions","models": [{"id": "<model ID from the platform model list>","name": "cloud_provider-main","reasoning": false,"input": ["text"],"contextWindow": <number from model documentation>,"maxTokens": <number from model documentation>,"compat": {"supportsDeveloperRole": false}}]}'
Pay attention to how apiKey is written. The outer single quotes prevent the shell from expanding ${CLOUD_API_KEY}, so it is passed to the tool as a literal string. Therefore, the template works only if the tool resolves this placeholder itself. Check the tool documentation first:
- If the tool supports reading environment variable placeholders, keep
${CLOUD_API_KEY}and confirm that the agent runtime can read the variable. - If the tool provides secret reference syntax or a secret file, use the method it provides.
- Do not remove the single quotes to make the shell expand the variable, and do not embed a plaintext key in the command. This would leave the key in command history.
The following table summarizes how to fill in each parameter.
| Parameter | Meaning | Guidance |
|---|---|---|
| baseUrl | Platform API address | Copy from platform documentation and pay attention to the version path |
| apiKey | Access credential | Read from an environment variable or secret reference; do not write plaintext |
| api | Protocol type | Keep consistent with platform documentation |
| id | Platform-side model identifier | Copy from the model list |
| reasoning | Whether to enable reasoning output | Set to false during initial integration testing |
| contextWindow | Context window length | Follow official documentation |
| maxTokens | Maximum output length per call | Follow official documentation and set it with cost in mind |
| compat.supportsDeveloperRole | Whether to use the developer role | Set to false when unsure and use system and user roles instead |
3. Set the Default Model
After provider registration is complete, set the model as the agent’s default primary model and set an alias that is easy to identify. The value of primary uses the format “provider name/model ID” and must match the provider name and model ID from the previous step.
openclaw config set 'agents.defaults.model' --json '{"primary": "cloud_provider/<model ID from the platform model list>"}'openclaw config set 'agents.defaults.models' --json '{"cloud_provider/<model ID from the platform model list>": {"alias": "cloud_provider"}}'
After configuration, perform a consistency check.
