> ## Documentation Index
> Fetch the complete documentation index at: https://docs.linkup.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Cerebras

> Use Linkup as a real-time web search tool for models served on Cerebras' ultra-fast inference platform

Cerebras provides ultra-fast inference (3,000+ tokens/sec) for open-source models. With Linkup, you can ground these models in real-time web data, giving them the ability to retrieve current facts, news, and source-backed information beyond their training data.

This guide demonstrates the integration using GPT-OSS 120B, but the same approach works with any model available on Cerebras that supports function calling.

**1. Get your API Keys**

> [card] [Get your Linkup API key](https://app.linkup.so/)
>
> Create a Linkup account for free to get your API key.

> [card] [Get your Cerebras API key](https://cloud.cerebras.ai/)
>
> Create a Cerebras account for free to get your API key.

**2. Install and Setup**

Install the required packages:

```bash theme={"system"}
pip install linkup-sdk cerebras-cloud-sdk
```

Set up your clients:

```python theme={"system"}
from cerebras.cloud.sdk import Cerebras
from linkup import LinkupClient
import json
from datetime import datetime

cerebras_client = Cerebras(api_key="your_cerebras_api_key")
linkup_client = LinkupClient(api_key="your_linkup_api_key")
```

**3. Define the Function Schema**

Tell Cerebras about your search function:

```python theme={"system"}
tools = [{
    "type": "function",
    "function": {
        "name": "search_web",
        "description": "Search the web for current information. Returns comprehensive content from relevant sources.",
        "parameters": {
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "The search query"
                }
            },
            "required": ["query"]
        }
    }
}]
```

**4. Build the Chatbot**

Put it all together in a conversational loop:

```python theme={"system"}
system_prompt = f"You are a helpful assistant. Today is {datetime.now().strftime('%B %d, %Y')}. Use web search when you need current information."
messages = [{"role": "system", "content": system_prompt}]

print("Chatbot ready! Type 'quit' to exit.\n")

while True:
    user_input = input("You: ").strip()
    if not user_input or user_input.lower() == "quit":
        break

    messages.append({"role": "user", "content": user_input})

    try:
        response = cerebras_client.chat.completions.create(
            model="gpt-oss-120b",
            messages=messages,
            tools=tools
        )

        message = response.choices[0].message

        while message.tool_calls:
            messages.append(message)
            for tool_call in message.tool_calls:
                args = json.loads(tool_call.function.arguments)
                print(f"Searching with Linkup: {args['query']}...")
                linkup_response = linkup_client.search(
                    query=args["query"],
                    depth="standard",
                    output_type="searchResults"
                )
                search_results = json.dumps(
                    [{"content": r.content} for r in linkup_response.results]
                )
                messages.append({
                    "role": "tool",
                    "tool_call_id": tool_call.id,
                    "content": search_results
                })

            response = cerebras_client.chat.completions.create(
                model="gpt-oss-120b",
                messages=messages,
                tools=tools
            )
            message = response.choices[0].message

        print(f"\nAssistant: {message.content}\n")
        messages.append({"role": "assistant", "content": message.content})

    except Exception as e:
        print(f"Error: {e}\n")
        messages.pop()
```

For more information, visit:

* [Cerebras Inference Documentation](https://inference-docs.cerebras.ai/)

> [!NOTE]
>
> **Need help?** Email `support@linkup.so`, ping us on [Discord](https://discord.com/invite/9q9mCYJa86), or [talk to us](https://calendar.app.google/zNUZz7RxgMMk9pKW7).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.