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

# Gateway to Other APIs

> Access any custom provider endpoint through Obiguard API

Obiguard API has first-class support for monitoring and routing your requests to 10+ provider endpoints, like `/chat/completions`, `/audio`, `/embeddings`, etc. We also make these endpoints work across 250+ different LLMs.

**However**, there are still many endpoints like Cohere's `/rerank` or Deepgram's `/listen` that are uncommon or have niche use cases.

With the **Gateway to Other APIs** feature, you can route to any custom provider endpoint using Obiguard (including the ones hosted on your private setups) and get **complete logging & monitoring** for all your requests.

## Supported HTTP Methods

<CardGroup cols={4}>
  <Card title="POST" color="#4CAF50" />

  <Card title="GET" color="#2196F3" />

  <Card title="PUT" color="#FF9800" />

  <Card title="DELETE" color="#F44336" />
</CardGroup>

Both the REST API and Obiguard SDKs (Python, NodeJS) support all of these HTTP methods.

# How to Integrate

1. Get your Obiguard API key
2. Add your provider details to Obiguard
3. Make your request using Obiguard's API or SDK

### 1. Get Obiguard API Key

Create or log in to your Obiguard account. Grab your account's API key from the ["Virtual Keys" page](https://app.obiguard.ai).

### 2. Add Provider Details

Choose one of these authentication methods:

<AccordionGroup>
  <Accordion title="Option 1. Generate a Virtual Key (Recommended)">
    Obiguard integrates with 40+ LLM providers. Add your provider credentials (such as API key) to Obiguard,
    and get a virtual key that you can use to authenticate and send your requests.

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

        client = Obiguard(
          obiguard_api_key="sk-obg***", # Your Obiguard API key
        )
        ```
      </Tab>

      <Tab title="cURL">
        ```sh cURL theme={null}
        curl https://gateway.obiguard.ai/v1/rerank \
          -H "Content-Type: application/json" \
          -H "x-obiguard-api-key: $OBIGUARD_API_KEY"
        ```
      </Tab>
    </Tabs>

    <Note>
      Creating virtual keys lets you:

      * Manage all credentials in one place
      * Rotate between different provider keys
    </Note>
  </Accordion>

  <Accordion title="Option 2. Direct Provider Auth">
    Set the provider name from one of Obiguard's 40+ supported providers list and use your provider credentials directly
    with each request.

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

        client = Obiguard(
          obiguard_api_key="sk-obg***",  # Your Obiguard API key
        )
        ```
      </Tab>

      <Tab title="cURL">
        ```sh cURL theme={null}
        curl https://gateway.obiguard.ai/v1/rerank \
          -H "Content-Type: application/json" \
          -H "x-obiguard-api-key: $OBIGUARD_API_KEY" \
          -H "x-obiguard-provider: cohere" \
          -H "Authorization: Bearer $COHERE_API_KEY" \
        ```
      </Tab>
    </Tabs>
  </Accordion>

  <Accordion title="Option 3. Custom Hosted Endpoint">
    Route to your privately hosted model endpoints.

    * Choose a compatible provider type (e.g., `openai`, `cohere`)
    * Provide your endpoint URL with `customHost`
    * Include `Authentication` if needed

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

        client = Obiguard(
          obiguard_api_key="sk-obg***",  # Your Obiguard API key
          provider = "cohere",
          custom_host = "https://182.145.24.5:8080/v1",
          Authorization = "Bearer COHERE_API_KEY"
        )
        ```
      </Tab>

      <Tab title="cURL">
        ```sh cURL theme={null}
        curl https://gateway.obiguard.ai/v1/rerank \
          -H "Content-Type: application/json" \
          -H "x-obiguard-api-key: $OBIGUARD_API_KEY" \
          -H "x-obiguard-provider: cohere" \
          -H "x-obiguard-custom-host: https://182.145.24.5:8080/v1" \
          -H "Authorization: Bearer $COHERE_API_KEY" \
        ```
      </Tab>
    </Tabs>
  </Accordion>
</AccordionGroup>

### 3. Make Requests

<Tabs>
  <Tab title="cURL">
    Construct your request URL:

    1. Obiguard Gateway base URL remains same: `https://gateway.obiguard.ai/v1`
    2. Append your custom endpoint at the end of the URL: `https://gateway.obiguard.ai/v1/{provider - endpoint}`

    <CodeGroup>
      ```bash POST theme={null}
      curl --request POST \
        --url https://gateway.obiguard.ai/v1/rerank \
        -H 'Content-Type: application/json' \
        -H "x-obiguard-api-key: $OBIGUARD_API_KEY" \
        --data '{
          "model": "rerank-english-v2.0",
          "query": "What is machine learning?",
          "documents": [
            "Machine learning is a branch of AI focused on building systems that learn from data.",
            "Data science involves analyzing and interpreting complex data sets."
          ]
        }'
      ```

      ```bash GET theme={null}
      curl --request GET \
        --url https://gateway.obiguard.ai/v1/collections \
        -H 'Content-Type: application/json' \
        -H "x-obiguard-api-key: $OBIGUARD_API_KEY"
      ```

      ```bash PUT theme={null}
      curl --request PUT \
        --url https://gateway.obiguard.ai/v1/collections/my-collection \
        -H 'Content-Type: application/json' \
        -H "x-obiguard-api-key: $OBIGUARD_API_KEY" \
        --data '{
          "metadata": {
            "description": "Updated collection description"
          }
        }'
      ```

      ```bash DELETE theme={null}
      curl --request DELETE \
        --url https://gateway.obiguard.ai/v1/collections/my-collection \
        -H 'Content-Type: application/json' \
        -H "x-obiguard-api-key: $OBIGUARD_API_KEY"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Python SDK">
    The SDK fully supports all HTTP methods: `POST`, `GET`, `PUT`, and `DELETE`.

    <CodeGroup>
      ```python POST theme={null}
      from obiguard import Obiguard

      client = Obiguard(
        obiguard_api_key="vk-obg***",  # Your Obiguard virtual key
      )

      response = client.post(
        '/rerank',
        model="rerank-english-v2.0",
        query="What is machine learning?",
        documents=[
          "Machine learning is a branch of AI focused on building systems that learn from data.",
          "Data science involves analyzing and interpreting complex data sets."
        ]
      )
      ```

      ```python GET theme={null}
      from obiguard import Obiguard

      client = Obiguard(
        obiguard_api_key="vk-obg***",  # Your Obiguard virtual key
      )

      response = client.get('/collections')
      ```

      ```python PUT theme={null}
      from obiguard import Obiguard

      client = Obiguard(
        obiguard_api_key="vk-obg***",  # Your Obiguard virtual key
      )

      response = client.put(
        '/collections/my-collection',
        metadata={
          "description": "Updated collection description"
        }
      )
      ```

      ```python DELETE theme={null}
      from obiguard import Obiguard

      client = Obiguard(
        obiguard_api_key="vk-obg***",  # Your Obiguard virtual key
      )

      response = client.delete('/collections/my-collection')
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## End-to-end Example

<Accordion title="Cohere Rerank Integration">
  A complete example showing document reranking with Cohere:

  ```python theme={null}
  from obiguard import Obiguard

  client = Obiguard(
    obiguard_api_key="vk-obg***",  # Your Obiguard virtual key
  )

  response = client.post(
    '/rerank',
    return_documents=False,
    max_chunks_per_doc=10,
    model="rerank-english-v2.0",
    query="What is the capital of the United States?",
    documents=[
      "Carson City is the capital city of the American state of Nevada.",
      "Washington, D.C. is the capital of the United States.",
      "Capital punishment has existed in the United States since before its founding."
    ]
  )
  ```
</Accordion>

# Caveats & Considerations

* Response objects are returned exactly as received from the provider, without Obiguard transformations
* REST API supports all HTTP methods: `POST`, `GET`, `PUT`, and `DELETE`
* SDK supports all HTTP methods: `POST`, `GET`, `PUT`, and `DELETE`
* There are no limitations on which provider endpoints can be proxied
* All requests are logged and monitored through your Obiguard dashboard

## Next Steps

The complete list of features supported in the SDK are 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>
