Use Haystack with Shannon
Use Haystack's OpenAIChatGenerator with api_base_url set to Shannon; pipelines, streaming and tools work through it.
- Tested Nov 7, 2026
- OpenAI Chat Completions
- About 2 min
About Haystack
Haystack is deepset's open-source Python framework for search, retrieval-augmented generation and agents, built from components joined in pipelines. Its OpenAI chat generator takes a base URL, so pipelines and agents can generate with Shannon models.
What you need
- A Shannon API key
- Keys & usage
- Base URL
-
https://api.shannon-ai.com/v1Endpoint:/v1/chat/completions - Every snippet below follows your choice.
Set it up
-
Install Haystack
Shellpip install haystack-ai -
Create the generator and stream
Haystack takes keys as
Secretobjects;Secret.from_env_varreads it when the component runs.Pythonfrom haystack.components.generators.chat import OpenAIChatGenerator from haystack.components.generators.utils import print_streaming_chunk from haystack.dataclasses import ChatMessage from haystack.utils import Secret llm = OpenAIChatGenerator( api_key=Secret.from_env_var("SHANNON_API_KEY"), model="Kimi-K3-uncensored-NVFP4", api_base_url="https://api.shannon-ai.com/v1", streaming_callback=print_streaming_chunk, ) llm.run([ChatMessage.from_user("Name three colours a cat can be.")]) -
Call tools
Pythonfrom haystack.tools import Tool weather = Tool( name="get_weather", description="Weather for a city", parameters={"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}, function=lambda city: f"Sunny in {city}", ) gen = OpenAIChatGenerator(api_key=Secret.from_env_var("SHANNON_API_KEY"), model="Kimi-K3-uncensored-NVFP4", api_base_url="https://api.shannon-ai.com/v1", tools=[weather]) print(gen.run([ChatMessage.from_user("What is the weather in Oslo?")])["replies"][0].tool_calls)
Check that it works
Send: Run the streaming sample with SHANNON_API_KEY set.
You should see: The colours printed as they stream in.
Models that fit Haystack
Every id below meets what Haystack needs. The first one is the default in the snippets.
| Model id | Context window | Max output | Image 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
- Haystack's embedders and document stores need an embedding model; Shannon does not serve
/v1/embeddings, so use another embedder for retrieval. Secret.from_token("...")works for quick tests but cannot be serialised with the pipeline.
Tips
- Haystack's
Agentcomponent takes this generator aschat_generatorand runs the tool loop for you. generation_kwargs={"max_completion_tokens": ...}caps the answer length.- Use the same generator in a RAG pipeline after a retriever and a
ChatPromptBuilder.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
None of the following authentication environment variables are set | SHANNON_API_KEY is not set. | Export it before running the pipeline. |
404 Not Found | api_base_url lacks /v1. | Use https://api.shannon-ai.com/v1. |
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 Haystack work with Shannon?
Yes, through OpenAIChatGenerator(api_base_url="https://api.shannon-ai.com/v1").
Do tools work?
Yes; the reply carries tool_calls, which we tested.