Install the client integration
Install langchain-openai in your Python environment. Generate a TextCortex API key, store it server-side as TEXTCORTEX_API_KEY, and choose an identifier from GET /models for TEXTCORTEX_MODEL.
The base URL is https://api.textcortex.com/v1. Do not append /chat/completions to a client base URL; the client constructs the endpoint.
Create a ChatOpenAI client
This minimal example uses the configured model. Change that identifier to evaluate another supported model while keeping the client configuration.
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
base_url="https://api.textcortex.com/v1",
api_key=os.environ["TEXTCORTEX_API_KEY"],
model=os.environ["TEXTCORTEX_MODEL"],
)
answer = llm.invoke("Hello")
print(answer.content)
Add capabilities one at a time
After the basic request works, add the streaming, tool schemas or output validation your chain needs. Check support for the exact TextCortex model route rather than assuming that all OpenAI client options are portable.
Pin the package versions you validate and keep a small request fixture set. This makes SDK upgrades and model changes easier to assess separately.
Keep routing and retrieval under your control
Use application configuration to select models for different chains. GPT, Claude, Gemini and open-weight models can share the TextCortex connection while serving different tasks.
If a chain retrieves documents, apply permissions before sending context to the model. For European processing requirements, select EU-hosted routes for every model call in the chain.
