Setup
- Install or update langchain-openai in the same environment as your application.
- Copy an exact model ID from TokenReply instead of guessing a provider alias.
- Set base_url to the gateway URL ending in /v1 and use your TokenReply API key.
- Run one non-streaming invoke before enabling agents, tools, or structured output.
from langchain_openai import ChatOpenAI
model = ChatOpenAI(
model="YOUR_MODEL_ID",
api_key="sk-your-token-here",
base_url="https://api.tokenreply.com/v1",
)
print(model.invoke("Reply with one short sentence.").content)
How to verify
- The first call returns an AIMessage with non-empty content.
- The request reaches /v1/chat/completions rather than duplicating /v1.
- A tool-calling workflow is tested separately with the exact selected model.
Limitations
- ChatOpenAI targets the standard OpenAI interface; provider-specific response fields may not be preserved.
- Catalog presence does not prove that every model supports tools, JSON schema, or image input.
- Use an endpoint-specific integration when the workflow depends on non-standard provider features.
Troubleshooting
| Symptom | What it usually means | What to do |
|---|
| The request URL contains /v1/v1 | The configured base URL and a framework prefix both include /v1. | Use the TokenReply SDK base URL exactly once and let LangChain append the operation path. |
|---|
| The model works in curl but not with an agent | The agent requires tool calling or structured output that the selected route may not expose. | Verify a plain chat call first, then test the required feature with that exact model. |
|---|