NativePort
← All use cases

Find relevant posts on X

Give your agent current X search results and source links for a specific question.

The problem

Simply opening X does not give your agent a reliable way to find current posts about a topic. Without a search tool, it may rely on things it remembers rather than what people are posting now. It needs the posts and their links before it can report what it found.

How NativePort helps

NativePort connects to Grok, xAI’s AI service, to search X for posts related to your question. Your agent can use the findings and their links to explain what people are discussing. The search provides relevant posts rather than every post about the subject.

Let your agent build it

You don’t need to write this code yourself. Copy the prompt and paste it into your agent. It will follow NativePort’s setup guide, help you use an existing account or create one, read this page, and ask what you’d like to do next.

View prompt
Help me use NativePort for this use case.

1. Read https://nativeport.ai/SKILL.md and follow its instructions to learn how to use NativePort. Save or update the skill if your environment supports it.

2. Check whether I already have a working NativePort connection or account. Reuse it if available. Otherwise, help me sign in or create an account by following the skill's setup instructions. Guide me through any steps that require me to use a browser, then help connect my agent. Keep credentials private.

3. Follow the skill to learn how to find the right tools, check their prices and instructions, and use them through NativePort.

4. Read this entire use-case page, including the instructions for agents inside the accordion: https://nativeport.ai/use-cases/search-x-posts/

Once setup is complete and you have read the page, briefly explain what you can help me do and ask me what I would like to do next. Wait for my answer before implementing the example or running paid tools.
Instructions for the agents - You don't need to read this

Technical implementation

Use Python 3 with requests installed (python -m pip install requests). Set NATIVEPORT_API_KEY in your environment to your NativePort key. Run the snippets on your server, where your key stays private.

Choose an available native model ID from GET /grok/v1/models that supports X search and set it as GROK_MODEL. The tool runs on the native Grok Responses route.

python
import os
import requests

BASE = "https://api.nativeport.ai"
HEADERS = {"Authorization": f"Bearer {os.environ['NATIVEPORT_API_KEY']}"}

response = requests.post(BASE + "/grok/v1/responses", headers=HEADERS,
    json={"model": os.environ["GROK_MODEL"],
          "input": "Find recent posts on X about accessible public transport. Cite the source posts.",
          "tools": [{"type": "x_search"}],
          "store": False}, timeout=180)
response.raise_for_status()
result = response.json()
for item in result.get("output", []):
    for part in item.get("content", []):
        if part.get("type") == "output_text":
            print(part["text"])
            print(part.get("annotations", []))

Keep citation annotations with the answer. Tool use has its own cost in addition to model processing. See X search options.

Tool costs

Tool used in the examplePrice per call
Grok — X search Varies by model, tokens, and X search usage

Prices in USD. Usage-based tools have no fixed per-call price. View pricing.