What is Haystack?
End-to-end NLP framework for building search, RAG, and question answering pipelines. Developed by deepset.
Searching X (Twitter) with Haystack
This integration lets your Haystack agent search X (Twitter) in real time via the Scavio API. The agent gets back structured JSON with post text, author handles, created_at timestamps, favorites, retweets, replies, quotes -- ready for reasoning and decision-making.
Setup
pip install scavio-haystackCode Example
Here is a complete Haystack agent that searches X (Twitter) using Scavio:
from haystack.components.generators import OpenAIGenerator
from haystack_integrations.components.websearch.scavio import ScavioWebSearch
# ScavioWebSearch wraps Google web search (POST /api/v2/google). For X (Twitter)
# data call POST /api/v1/x/search directly - see the X (Twitter) guide.
# export SCAVIO_API_KEY=sk_live_your_key
web_search = ScavioWebSearch(top_k=5)
results = web_search.run(query="AI agents")
context = "\n".join(doc.content for doc in results["documents"])
generator = OpenAIGenerator(model="gpt-5.5")
response = generator.run(
prompt="Summarise these search results:\n" + context
)
print(response["replies"][0])Full Working Example
A production-ready example with error handling:
from haystack import Pipeline
from haystack.components.builders import PromptBuilder
from haystack.components.generators import OpenAIGenerator
from haystack_integrations.components.websearch.scavio import ScavioWebSearch
# ScavioWebSearch wraps Google web search (POST /api/v2/google). For X (Twitter)
# data call POST /api/v1/x/search directly - see the X (Twitter) guide.
# export SCAVIO_API_KEY=sk_live_your_key
template = """
Based on these web search results, answer the question.
{% for doc in documents %}{{ doc.content }}
{% endfor %}
Question: {{ query }}
Answer:
"""
pipe = Pipeline()
pipe.add_component("search", ScavioWebSearch(top_k=5))
pipe.add_component("prompt_builder", PromptBuilder(template=template))
pipe.add_component("llm", OpenAIGenerator(model="gpt-5.5"))
pipe.connect("search.documents", "prompt_builder.documents")
pipe.connect("prompt_builder", "llm")
query = "AI agents"
result = pipe.run({"search": {"query": query}, "prompt_builder": {"query": query}})
print(result["llm"]["replies"][0])Pricing
Scavio offers a free tier with 50 credits on signup (1 credit per search). No credit card required. This is enough to build and test your Haystack integration. Paid plans start at $30/month for higher volumes.