no key · no human
For agentsModels › Llama

Llama + live news

Open weights, so the endpoint is whoever you rent or your own machine. The example uses Groq for speed; Together, Fireworks, Bedrock, Ollama and vLLM all expose the same shape.

VendorMeta, United States
Base URLhttps://api.groq.com/openai/v1
Model idllama-3.3-70b-versatile
Model credentialGROQ_API_KEY
Tool formatOpenAI-compatible — the tool schema below is the same one every other OpenAI-shaped provider takes. Only the base URL and model name change.
News API keynone required
Vendor docshttps://www.llama.com/docs/

Base URLs and model ids change often, and several vendors run separate mainland and international endpoints with non-interchangeable keys. Check the vendor docs above before copying. The part that does not change is the tool itself — our API has no key, no version negotiation and no SDK.

Working example

python
import json, os, requests
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["GROQ_API_KEY"],
    base_url="https://api.groq.com/openai/v1",
)

TOOLS = [{
    "type": "function",
    "function": {
        "name": "search_news",
        "description": ("Search worldwide news published in the last 30 days. "
                        "Free, keyless. Use 2-5 keywords, not a question."),
        "parameters": {
            "type": "object",
            "properties": {
                "q":    {"type": "string"},
                "date": {"type": "string",
                          "enum": ["today", "yesterday", "24h", "7d", "30d"]},
                "lang": {"type": "string"},
                "size": {"type": "integer"},
            },
            "required": ["q"],
        },
    },
}]

IDENT = {                       # optional, but it is what keeps this API open
    "agent_name": "news-agent",
    "software": "llama",
    "model": "llama-3.3-70b-versatile",
}

msgs = [{"role": "user", "content": "What happened with grain exports this week?"}]
while True:
    r = client.chat.completions.create(
        model="llama-3.3-70b-versatile", messages=msgs, tools=TOOLS)
    msg = r.choices[0].message
    msgs.append(msg)
    if not msg.tool_calls:
        print(msg.content)
        break
    for tc in msg.tool_calls:
        args = json.loads(tc.function.arguments)
        data = requests.get("https://freenewsapi.ai/v1/search",
                            params={**args, **IDENT}, timeout=20).json()
        msgs.append({"role": "tool", "tool_call_id": tc.id,
                     "content": json.dumps(data)[:60000]})

Worth knowing about Llama

  • Tool-calling quality varies sharply by size. The 70B class is reliable; the 8B class needs a forced tool choice or prompt-level emulation.
  • Every host prefixes model names differently. The schema does not change, only the string.

Test the tool without the model

Before debugging a tool-calling loop, confirm the data side works. It needs no credentials, so this runs anywhere:

bash
curl "https://freenewsapi.ai/v1/search?q=grain+exports&date=7d&size=5"

If that returns results and your loop still fails, the problem is in the model's tool handling, not in the data.

Prompt it properly

The single most common failure is the model phrasing the query as a sentence. Search is AND across every term, so q=what happened with grain exports matches nothing. Put this in the system prompt:

system prompt
Use search_news for anything about current events or recent developments.
Phrase the query as 2-5 keywords that would appear in a headline, never as a question.
Good: "grain export prices". Bad: "what is happening with grain exports".
Scan titles first. Only request full_text for articles you will actually cite.
If a search returns nothing, drop the least essential keyword and try once more.
No results means no coverage in this corpus \u2014 not that the event did not happen.

More in system prompts.

Same format

Llama uses the openai tool-calling shape. These take the same code with a different base URL and model name: Qwen, DeepSeek, MiniMax, Kimi, GLM.

← All models · Identify your agent · Token costs