Bring your own model
Connect your own model endpoint to LagrangeCloud, then choose it for an agent
or a run. Your provider bills model inference; Lagrange's compute charges and
credit requirements still apply. Connection tests also make model requests.
max_cost_usd is a best-effort run guard, not a provider spending cap. One
model call can exceed it, so configure spending controls with your provider and
use a time limit for untrusted or potentially long-running tasks.
What you need
Have a public HTTPS endpoint, its API key, and the exact model ID ready. The endpoint must support the API format used by your harness:
| Harness | Required API format | Example base URL |
|---|---|---|
| Codex | OpenAI Responses | https://provider.example/v1 |
| Claude Code | Anthropic Messages | https://provider.example |
An endpoint offering only OpenAI Chat Completions is insufficient for Codex. The model also needs to support the tool use required by your agent. A model appearing in a provider's catalog does not establish that compatibility. Other harnesses do not yet support these custom connections.
Local addresses such as localhost, private network endpoints, and HTTP
endpoints are not supported in this release. Local and private models need a
connector, which is planned for a later phase. With hosted Lagrange, local
inference would still send prompts and responses through Lagrange.
Add a connection
- Open Settings → Models, then Your model connections.
- Enter a connection name and select its API format.
- Enter the provider's base URL and API key, then choose Add connection.
Use the base URL, rather than the full
/responsesor/v1/messagesURL. - Enter the exact model ID in the connection's test form and choose Test connection.
- Wait for the result shown below that connection. Test connection stays disabled while the diagnostic is pending to prevent duplicate requests. Open View diagnostic run to inspect its trace.
The test runs an isolated, short task through the selected harness. It asks for a shell tool call and verifies both the tool's output and the final reply. A pass establishes that this interaction worked with that model and connection; it does not certify every feature or future task. Test each model you intend to use, including advanced model choices.
If adding connections is disabled, ask the deployment administrator to enable encrypted credential storage. If a test says that the sandbox egress proxy is required, the deployment administrator must configure that proxy before the connection can run.
Choose the connection for an agent or run
Open the agent's model settings, choose your connection under Model connection, and enter the exact Model ID. Save the agent settings to create a new version. You can also select the connection and model when starting a run. Leaving run overrides unset keeps the agent's model settings. You can override an agent's model for one run without changing its saved version. Deployment verification always uses the saved version's settings instead of run overrides.
Blank advanced fields preserve inheritance; Use harness default explicitly clears an inherited slot. Switching connections discards names and advanced slots from the previous connection, so choose model IDs for the new endpoint. Run again on an inline run preserves its connection, model slots and limits.
The selected harness must match the connection's API format. Advanced model slots use the same connection. In a multi-step workflow using custom models, every step must use that same connection.
If you use the API, reference the connection ID returned when you create it:
{
"harness": "codex",
"task": "Reply hello",
"model": {
"connection": "mc_your_connection_id",
"name": "your-provider-model-id"
}
}See the API reference for connection endpoints. Credentials belong to the project. Agent and run settings contain a connection reference, rather than the key itself.
Troubleshoot a failed connection
| Symptom | What to check |
|---|---|
| Authentication rejected | Check the key's validity and provider permissions. |
| Model not found | Use the exact ID accepted by the configured endpoint. |
| Endpoint unavailable | Check the provider's status and that its URL is public HTTPS. |
| Basic responses work but the diagnostic fails | Check API format, streaming, and tool-call support in the diagnostic trace. |
| Diagnostic interrupted | Check the trace and retry after connectivity returns. |
A browser disconnect does not itself restart the run. Reopen the run page to see saved events and current status. If the model request was interrupted, partial output may remain in the trace. Where a resumable harness session is available, a follow-up can continue it; it cannot restore generation at an exact token. Check previous tool results before repeating tasks with external effects. The harness may retry individual model requests before reporting a failure; Lagrange does not automatically repeat the whole run. A custom Messages response that ends without a terminal provider stop reason is marked failed, even if partial text was received. A failed custom connection does not silently switch to a platform model.
Provider errors keep useful status and error-code details in the trace, but Lagrange redacts exact runtime credentials, provider-style API-key fragments, and bearer tokens before persisting them.
To replace a key, add a new connection and update the agents or run selections that use it. Deleting a connection stops future requests from resolving it; already resolved or active runs retain their existing access until they end. Cancel those runs if you also need to stop that work. Provider-side key revocation is separate from deleting the Lagrange connection.