weightsapi.INFERENCEConsole
Navigation
LangChain (Python)

LangChain (Python)

Configure LangChain (Python) with the WeightsAPI OpenAI-compatible endpoint.

Before you connect#

AI access requires sign-in, one confirmed top-up of at least USD 100, an authorized API key and enough available credit for the request. Each later top-up also has a USD 100 minimum; smaller remaining balances stay usable when they cover the request. Credit requires transaction verification. Check service status for model availability before sending traffic. Use your own API key without the Bearer prefix in key fields. The base URL already includes /v1. These configurations were checked against official documentation, not tested against a live GPU deployment.

Configuration#

Install langchain-openai, then:

import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="Qwen/Qwen3-32B",
    base_url=os.environ["https://weightsapi.com/v1"],
    api_key=os.environ["WEIGHTSAPI_API_KEY"],
)
print(llm.invoke("Say hello in one sentence.").content)

For JavaScript, ChatOpenAI from @langchain/openai takes model, apiKey, and configuration: { baseURL: ... }. Standard fields are supported; LangChain says provider-specific response fields may not be preserved by ChatOpenAI.

Sources: Python compatible providers, JavaScript compatible providers.

Verify the connection#

Fetch the model list, then send one short message. A successful model list does not prove tools, vision or JSON schema support. Check the selected deployment’s capabilities before enabling them.