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

# DeepSeek

> Obiguard provides a robust and secure gateway to facilitate the integration of various Large Language Models (LLMs) into your applications, including DeepSeek models.

With Obiguard, you can take advantage of features like fast AI gateway access, observability, prompt management, and more, all while ensuring the secure management of your LLM API keys through a [virtual key](/virtual-keys) system.

<Note>
  Provider Slug: **deepseek**
</Note>

## Obiguard SDK Integration with DeepSeek Models

Obiguard provides a consistent API to interact with models from various providers. To integrate DeepSeek with Obiguard:

### 1. Install the Obiguard SDK

Add the Obiguard SDK to your application to interact with DeepSeek AI's API through Obiguard's gateway.

<Tabs>
  <Tab title="Python SDK">
    ```sh theme={null}
    pip install obiguard
    ```
  </Tab>
</Tabs>

### 2. Initialize Obiguard with the Virtual Key

To use DeepSeek with Obiguard, [get your API key from here](https://platform.deepseek.com/api_keys), then add it to Obiguard to create the virtual key.

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    from obiguard import Obiguard

    client = Obiguard(
        obiguard_api_key="sk-obg***",  # Your Obiguard API key
        virtual_key="VIRTUAL_KEY"   # Replace with your virtual key for DeepSeek
    )
    ```
  </Tab>
</Tabs>

### 3. Invoke Chat Completions with DeepSeek

Use the Obiguard instance to send requests to DeepSeek. You can also override the virtual key directly in the API call if needed.

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    completion = client.chat.completions.create(
        messages= [{ "role": 'user', "content": 'Say this is a test' }],
        model= 'deepseek-chat'
    )
    ```
  </Tab>
</Tabs>

### 4. Invoke Multi-round Conversation with DeepSeek

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    from obiguard import Obiguard

    client = Obiguard(
        obiguard_api_key="sk-obg***",  # Your Obiguard API key
        virtual_key="VIRTUAL_KEY"   # Replace with your virtual key for DeepSeek
    )

    # Round 1
    messages = [{"role": "user", "content": "What's the highest mountain in the world?"}]
    response = client.chat.completions.create(
        model="deepseek-chat",
        messages=messages
    )

    messages.append(response.choices[0].message)
    print(f"Messages Round 1: {messages}")

    # Round 2
    messages.append({"role": "user", "content": "What is the second?"})
    response = client.chat.completions.create(
        model="deepseek-chat",
        messages=messages
    )

    messages.append(response.choices[0].message)
    print(f"Messages Round 2: {messages}")
    ```
  </Tab>
</Tabs>

### 5. JSON Output with DeepSeek

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    import json
    from obiguard import Obiguard

    client = Obiguard(
        obiguard_api_key="sk-obg***",  # Your Obiguard API key
        virtual_key="VIRTUAL_KEY"   # Replace with your virtual key for DeepSeek
    )

    system_prompt = """
    The user will provide some exam text. Please parse the "question" and "answer" and output them in JSON format.

    EXAMPLE INPUT:
    Which is the highest mountain in the world? Mount Everest.

    EXAMPLE JSON OUTPUT:
    {
        "question": "Which is the highest mountain in the world?",
        "answer": "Mount Everest"
    }
    """

    user_prompt = "Which is the longest river in the world? The Nile River."

    messages = [{"role": "system", "content": system_prompt},
                {"role": "user", "content": user_prompt}]

    response = client.chat.completions.create(
        model="deepseek-chat",
        messages=messages,
        response_format={
            'type': 'json_object'
        }
    )

    print(json.loads(response.choices[0].message.content))
    ```
  </Tab>
</Tabs>

### Supported Endpoints

1. `CHAT_COMPLETIONS`
2. `STREAM_CHAT_COMPLETIONS`

The complete list of features supported in the SDK is available on the link below.

<Card title="Obiguard SDK Client" icon="code" href="/api-reference/sdk/python">
  Learn more about the Obiguard SDK Client
</Card>
