LangChain
Point LangChain's ChatOpenAI at PromptsForLess Chat Completions for text, streaming, tool calls and structured output.
LangChain's ChatOpenAI accepts a custom base URL. Point it at PromptsForLess and keep it on Chat Completions.
Install and configure
Install langchain-openai in your Python environment:
pip install langchain-openaiStore your key from the dashboard as PFL_API_KEY, then create the client:
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="deepseek-v4.1-flash",
base_url="https://api.promptsforless.com/v1",
api_key=os.environ["PFL_API_KEY"],
use_responses_api=False,
)
reply = llm.invoke("Write one sentence about the ocean.")
print(reply.content)
print(reply.usage_metadata)Swap in any model ID from the catalog. LangChain's ChatOpenAI guide documents the base URL setting and notes that it drops non-standard response fields.
Stream a response
for chunk in llm.stream("Write a short greeting."):
print(chunk.content, end="", flush=True)
print()Add tools and structured output
PromptsForLess supports tool calls and structured outputs, so LangChain's bind_tools and with_structured_output work as usual. Pick a model with tool calling for agents.
Keep use_responses_api=False. Responses-only LangChain features, such as built-in web search, file search and conversation IDs, are outside this setup.
Troubleshooting
| Symptom | Fix |
|---|---|
Requests go to /responses | Remove Responses-only options and built-in tools, and keep use_responses_api=False. |
| A field is missing from the reply | ChatOpenAI drops non-standard response fields. |
| Authentication fails | Check your key with the quickstart request. |
| Agent tools fail after text works | Pick a model with tool calling. |
Find model IDs and prices in the catalog.