Skip to content
LangChain

Frameworks and SDKs

Use LangChain with Shannon

Use ChatOpenAI with Shannon's base URL; chains, agents and tool binding work unchanged.

  • Tested Nov 7, 2026
  • OpenAI Chat Completions
  • About 2 min

About LangChain

LangChain is an open-source framework for building applications and agents on language models, in Python and JavaScript. ChatOpenAI from the langchain-openai package takes a base URL, so LangChain chains, agents and LangGraph graphs can run on Shannon models.

What you need

A Shannon API key
Keys & usage
Base URL
https://api.shannon-ai.com/v1 Endpoint: /v1/chat/completions
Every snippet below follows your choice.

Set it up

  1. Install the OpenAI integration

    Shell
    pip install langchain-openai
  2. Create the model

    ChatOpenAI takes Shannon's base URL and key; everything built on it (chains, agents, LangGraph) follows.

    Python
    from langchain_openai import ChatOpenAI
    
    llm = ChatOpenAI(model="Kimi-K3-uncensored-NVFP4", base_url="https://api.shannon-ai.com/v1", api_key="YOUR_API_KEY")
    print(llm.invoke("Say hello to a dog in five words.").content)
  3. Bind tools

    Python
    def get_weather(city: str) -> str:
        """Weather for a city."""
        ...
    
    msg = llm.bind_tools([get_weather]).invoke("What is the weather in Rome?")
    print(msg.tool_calls)  # [{'name': 'get_weather', 'args': {'city': 'Rome'}, ...}]

Check that it works

Send: Run the first sample.

You should see: A five-word greeting, e.g. "Hello, good dog, nice pup!"

Models that fit LangChain

Every id below meets what LangChain needs. The first one is the default in the snippets.

Model idContext windowMax outputImage input
Kimi-K3-uncensored-NVFP4 1,022,976 262,144 Yes
Kimi-K3-uncensored-3BIT-REAP 225,280 225,280 Yes
shannon-3 196,608 65,536 Yes
shannon-coder-1 131,072 65,536 No

Good to know

  • ChatOpenAI drops reasoning_content; read the reasoning with the OpenAI SDK directly if you need it.
  • ChatAnthropic(base_url="https://api.shannon-ai.com", ...) reaches the Anthropic format instead.
  • LangChain's retrieval needs embeddings, which Shannon does not serve; pair it with a separate embedding model.

Tips

  1. Set OPENAI_BASE_URL and OPENAI_API_KEY in the environment so every ChatOpenAI in the app uses Shannon without arguments.
  2. Ask for typed results with with_structured_output(MySchema, method="function_calling"): it goes through tool calls, which every model in the picker supports (LangChain's default method is json_schema).
  3. Pass max_retries and timeout to ChatOpenAI for long-running jobs.
  4. Use model.stream(...) or astream(...) to show answers as they are written.

Troubleshooting

SymptomCauseFix
404 Not Found base_url lacks /v1. Use https://api.shannon-ai.com/v1.
tool_calls is empty A model that answered in text. Use a model from the picker; all of them call tools.
401 Unauthorized The key is missing, mistyped or rotated. Copy the key again from Keys & usage; it starts with sk-.
context_length_exceeded / "prompt is too long" The conversation is longer than the model's window. Start a new chat, let the tool compact it, or pick a model with a larger window.
insufficient_quota Your balance cannot pay for the request. Top up or change plan; the request is not retried by itself.

Questions

Does LangChain work with Shannon?

Yes, through ChatOpenAI with base_url="https://api.shannon-ai.com/v1".

Does LangGraph work?

Yes: LangGraph agents take the same ChatOpenAI model.

Choose your language

All languages are equal. Pick the one you want to browse in.

Europe

Middle East & North Africa

South Asia

Southeast Asia

East Asia

Central Asia & Caucasus

Africa

Oceania

Constructed & Classical