> ## 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.

# SambaNova

> Use Linkup as a real-time web search tool for models served on SambaCloud's high-speed inference platform

SambaCloud provides sub-second inference on open models like Llama and DeepSeek. 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 SambaCloud that supports function calling.

For a deeper walkthrough of this pairing, see our blog post: [How to Ground SambaNova LLMs with Real-Time Web Search Using Linkup](https://www.linkup.so/blog/sambanova-with-web-search-using-linkup).

<Steps>
  <Step title="Get your API Keys">
    <CardGroup cols={2}>
      <Card title="Get your Linkup API key" icon="key" href="https://app.linkup.so/" horizontal="True">
        Create a Linkup account for free to get your API key.
      </Card>

      <Card title="Get your SambaCloud API key" icon="key" href="https://cloud.sambanova.ai/apis" horizontal="True">
        Create a SambaCloud account for free to get your API key.
      </Card>
    </CardGroup>
  </Step>

  <Step title="Set Up Your Environment">
    Initialize your project and create a virtual environment (Python 3.10+):

    ```bash theme={"system"}
    mkdir sambanova-linkup
    cd sambanova-linkup
    python3 -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    ```

    Install dependencies:

    ```bash theme={"system"}
    pip install linkup-sdk==0.19.0 sambanova==1.2.0
    ```

    <Note>
      SambaNova's [sample notebook](https://github.com/sambanova/integrations/tree/main/linkup) still pins `linkup-sdk==0.9.0`. This tutorial uses the current Linkup SDK (`0.19.0`).
    </Note>

    Configure your API keys as environment variables:

    <CodeGroup>
      ```bash Mac / Linux theme={"system"}
      export LINKUP_API_KEY=paste_your_linkup_key_here
      export SAMBANOVA_API_KEY=paste_your_sambanova_key_here
      ```

      ```bash Windows theme={"system"}
      set LINKUP_API_KEY=paste_your_linkup_key_here
      set SAMBANOVA_API_KEY=paste_your_sambanova_key_here
      ```
    </CodeGroup>
  </Step>

  <Step title="Build the Agent">
    Create a file named `agent.py` and add the following code:

    ```python agent.py theme={"system"}
    import os
    import json
    from datetime import datetime
    from linkup import LinkupClient
    from sambanova import SambaNova

    linkup_client = LinkupClient(api_key=os.environ.get("LINKUP_API_KEY"))
    sambanova_client = SambaNova(api_key=os.environ.get("SAMBANOVA_API_KEY"))

    tools = [{
        "type": "function",
        "function": {
            "name": "search_web",
            "description": "Search the web for current or verifiable information. Make the query specific: say what to find and which facts to return. Return source URLs. If no reliable source is found, say so.",
            "parameters": {
                "type": "object",
                "properties": {
                    "query": {
                        "type": "string",
                        "description": "The search query"
                    }
                },
                "required": ["query"]
            }
        }
    }]

    def main():
        print("--- SambaNova + Linkup ---")
        print("Type 'quit' to exit.\n")

        today_str = datetime.now().strftime("%B %d, %Y")
        system_prompt = (
            f"You are a helpful assistant. Today is {today_str}. "
            f"Use web search for current or verifiable information. "
            f"Prefer searching when facts could be outdated, and cite source URLs."
        )

        history = [{"role": "system", "content": system_prompt}]

        while True:
            try:
                user_input = input("You: ")
                if user_input.lower() in ["quit", "exit"]:
                    print("Goodbye!")
                    break

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

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

                while message.tool_calls:
                    history.append(message)
                    for tc in message.tool_calls:
                        q = json.loads(tc.function.arguments)["query"]
                        print(f"Searching using Linkup: {q}...")
                        try:
                            result = linkup_client.search(
                                query=q,
                                depth="standard",
                                output_type="sourcedAnswer"
                            )
                            content = json.dumps(result.model_dump())
                        except Exception as e:
                            content = f"Search error: {e}"
                        history.append({
                            "role": "tool",
                            "name": "search_web",
                            "tool_call_id": tc.id,
                            "content": content
                        })

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

                print(f"Agent: {message.content}\n")
                history.append(message)

            except Exception as e:
                print(f"Error: {e}")

    if __name__ == "__main__":
        main()
    ```
  </Step>

  <Step title="Run the Agent">
    ```bash theme={"system"}
    python agent.py
    ```
  </Step>

  <Step title="Try Different Scenarios">
    **Internal knowledge (no tool call):**

    ```
    You: What is the definition of philosophy?
    Agent: Philosophy is the study of fundamental questions about existence,
           knowledge, values, reason, mind, and language...
    ```

    **Tool-augmented reasoning:**

    ```
    You: What models are currently available on SambaCloud? Include the latest update date and cite the source URLs.
    Searching using Linkup: SambaCloud available models latest update...
    Agent: Synthesizes a sourced response grounded in current web results via Linkup.
    ```
  </Step>
</Steps>

For more information, visit:

* [How to Ground SambaNova LLMs with Real-Time Web Search Using Linkup](https://www.linkup.so/blog/sambanova-with-web-search-using-linkup)
* [SambaNova official Linkup notebook](https://github.com/sambanova/integrations/tree/main/linkup)
* [SambaCloud Documentation](https://cloud.sambanova.ai/)

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