Troubleshoot
Common issues and solutions when migrating an existing OpenAI application to OLLM.
This guide helps you diagnose and resolve common issues encountered when migrating an existing OpenAI API application to OLLM.
If your migrated application fails to connect, returns authentication errors, or produces unexpected output, use the sections below to isolate the problem.
Client Configuration Issues
base_url Not Updated
The most common migration mistake is forgetting to set base_url on the client. If you initialize the SDK without it, requests will route to OpenAI instead of OLLM.
Your client must be:
from openai import OpenAI
client = OpenAI(
base_url="https://api.ollm.com/v1",
api_key="your-ollm-api-key"
)Common mistakes include:
- Omitting
base_urlentirely (the SDK defaults to OpenAI) - Using
https://api.ollm.comwithout/v1 - Adding a trailing path such as
/chat/completions
The correct base URL is:
https://api.ollm.com/v1Node.js: Using apiKey Instead of baseURL
In the Node.js SDK, the option is baseURL (capital URL), not baseUrl.
const client = new OpenAI({
baseURL: "https://api.ollm.com/v1", // correct
apiKey: "your-ollm-api-key"
});Using baseUrl (lowercase) will be silently ignored and requests will route to OpenAI.
Old OpenAI Key Still in Use
If you updated base_url but forgot to replace the API key, requests will be rejected with a 401.
Confirm which key your application is loading:
echo $OLLM_API_KEYIf nothing prints, the variable is not set. Ensure your client reads the correct variable:
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.ollm.com/v1",
api_key=os.environ["OLLM_API_KEY"]
)Do not mix OPENAI_API_KEY and OLLM_API_KEY in the same environment.
Authentication Errors (401)
If you receive:
401 UnauthorizedThe request reached OLLM but was rejected due to a credentials problem.
Common causes:
- OpenAI API key passed instead of OLLM key
- API key revoked or not yet activated
- Environment variable pointing to wrong value
base_urlstill set to OpenAI, sending the OLLM key to the wrong endpoint
Resolution Steps
- Regenerate your API key in the OLLM dashboard.
- Update your environment variable and confirm with
echo $OLLM_API_KEY. - Verify
base_urlishttps://api.ollm.com/v1. - Restart your application after updating environment variables.
Do not retry repeatedly without correcting credentials first.
Model Errors
Model Not Found After Migration
OLLM model IDs differ from OpenAI model IDs. If you migrated without updating the model field, the request will fail even if authentication succeeds.
Replace OpenAI model names with OLLM equivalents:
| OpenAI Model | OLLM Equivalent |
|---|---|
gpt-4o | near/GLM-4.6 |
gpt-4-turbo | near/GLM-4.7 |
Example of correct usage:
response = client.chat.completions.create(
model="near/GLM-4.6",
messages=[{"role": "user", "content": "Test"}]
)Browse available model IDs in the OLLM console.
Model ID Format
OLLM model IDs use the format provider/model-name. Ensure you are not passing a plain model name without the provider prefix.
Correct:
near/GLM-4.6Incorrect:
GLM-4.6
glm-4.6Response Handling Issues
Attribute Errors When Accessing Response
If your application crashes at:
response.choices[0].message.contentThe response may contain an error envelope or an empty choices array. Always guard response access:
if hasattr(response, "choices") and response.choices:
print(response.choices[0].message.content)This is the same pattern you would use with the OpenAI SDK and requires no migration-specific changes.
Empty or Unexpected Output
If the response returns successfully but content is empty or different from your OpenAI baseline:
- Confirm you updated the
modelfield to a valid OLLM model - Log the full response object to inspect the raw output
- Check token usage to verify the prompt was processed correctly
print(response)
print(response.usage.total_tokens)If token usage is unusually low, the prompt may be malformed or truncated.
Streaming Issues
Streaming works identically after migration. If streaming breaks after switching to OLLM, the issue is likely configuration rather than streaming itself.
Confirm:
base_urlandapi_keyare updated on the same client used for streaming- You are iterating correctly over chunks
- You are checking for
deltabefore accessing content
for chunk in stream:
if chunk.choices and chunk.choices[0].delta:
print(chunk.choices[0].delta.get("content", ""), end="")If streaming hangs, test the same request without stream=True to isolate whether the issue is streaming-specific or a general connection problem.
Token and Context Errors
If you encounter context length or token limit errors after migration:
- Different OLLM models have different context window sizes than OpenAI models
- Large prompts that worked with GPT-4 may exceed a different model's context limit
Safeguard large inputs:
MAX_CHARS = 20000
prompt = prompt[:MAX_CHARS]Monitor token consumption:
print(response.usage.total_tokens)If token usage is significantly higher than expected, review the model's context window in the OLLM console.
Network or Timeout Errors
If requests time out or fail intermittently after migration:
- Confirm outbound HTTPS is allowed to
api.ollm.comin your environment - Add explicit timeout controls if your previous OpenAI integration used them
response = client.chat.completions.create(
model="near/GLM-4.6",
messages=[{"role": "user", "content": "Test"}],
timeout=30
)Avoid retrying 401 or model-not-found errors — these require a configuration fix, not a retry.
Verification & Dashboard Cross-Check
If you are unsure whether the migrated request is reaching OLLM:
- Open the OLLM dashboard and check the request logs
- Confirm the request appears with a Success or Verified status
- Check model name and token count match what your application sent
If no request appears in the dashboard, the issue is local — your client is still routing to OpenAI or failing before the request is sent.
Debugging Checklist
Before escalating issues, confirm:
base_urlis exactlyhttps://api.ollm.com/v1- The OLLM API key is set and loaded (not the OpenAI key)
- The
modelfield uses an OLLM model ID (e.g.,near/GLM-4.6) - The request is visible in the OLLM dashboard
- Response access is guarded before reading
choices - Token limits for the selected model have not been exceeded
Working through these checks will isolate most migration issues quickly.