TokenReply

Loading…

Reload

LangChain with TokenReply

Install the official LangChain OpenAI package, set base_url to the TokenReply /v1 URL, and pass a model ID copied from the live catalog.

Last checked · Sources: Official client documentation and TokenReply route review

Category
Framework
API format
OpenAI Chat Completions
Endpoint setting
Base URL ending in /v1

Setup

  1. Install or update langchain-openai in the same environment as your application.
  2. Copy an exact model ID from TokenReply instead of guessing a provider alias.
  3. Set base_url to the gateway URL ending in /v1 and use your TokenReply API key.
  4. Run one non-streaming invoke before enabling agents, tools, or structured output.
Example
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

SymptomWhat it usually meansWhat to do
The request URL contains /v1/v1The 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 agentThe 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.

Resources

Ready to try it?