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

# OpenAI-compatible clients

> The generic recipe for connecting any OpenAI-compatible SDK or app to Valkyrie.

Valkyrie serves models through the OpenAI Chat Completions API, so any client that
lets you set a **base URL** and **API key** can talk to a Valkyrie deployment.

## The three values you need

| Setting | Value |
| - | - |
| Base URL | `https://valkyrie-back.azumo.com/{deployment_slug}/v1` |
| API key | Your deployment key (`vk_dep_`) |
| Model | Your deployment slug (or [alias](https://docs.valkyrieapp.azumo.com/guides/aliases.md)) |

The **deployment slug** looks like `deployment-{id}` (for example `deployment-227`).
With an alias, the base URL becomes
`https://valkyrie-back.azumo.com/{account_slug}/{alias}/v1`.

### Where to find them

* **All three at once:** on the endpoint's page, click **Create a key for this
  endpoint**. The key is shown once with environment variables (`OPENAI_BASE_URL`,
  `OPENAI_API_KEY`, `OPENAI_MODEL`) and a curl test, ready to paste. This works
  while the endpoint is running, paused, or off on its schedule. See
  [Create a key for an endpoint](https://docs.valkyrieapp.azumo.com/dashboard/endpoints.md#create-a-key-for-an-endpoint).
* **The URL:** the endpoint's page shows it while the model is running.
* **A key:** the [API keys](https://docs.valkyrieapp.azumo.com/dashboard/api-keys.md) screen.

> [!NOTE]
>
> Requests succeed only while the endpoint is running. If it is **Off (schedule)**,
> its badge says when it starts again; if it is paused or stopped, someone has to
> resume or start it. See [Deployment status](https://docs.valkyrieapp.azumo.com/guides/deployment-status.md#statuses).

## Official OpenAI SDKs

```python Python theme={null}
from openai import OpenAI

client = OpenAI(
    base_url="https://valkyrie-back.azumo.com/{deployment_slug}/v1",
    api_key="YOUR_VALKYRIE_API_KEY",
)

resp = client.chat.completions.create(
    model="{deployment_slug}",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
```

```typescript TypeScript theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://valkyrie-back.azumo.com/{deployment_slug}/v1",
  apiKey: process.env.VALKYRIE_API_KEY,
});

const resp = await client.chat.completions.create({
  model: "{deployment_slug}",
  messages: [{ role: "user", content: "Hello!" }],
});
console.log(resp.choices[0].message.content);
```

## LangChain

```python theme={null}
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    base_url="https://valkyrie-back.azumo.com/{deployment_slug}/v1",
    api_key="YOUR_VALKYRIE_API_KEY",
    model="{deployment_slug}",
)
print(llm.invoke("Hello!").content)
```

## Anything else

Any app with an "OpenAI-compatible" or "custom OpenAI endpoint" setting works the
same way, LibreChat, Open WebUI, editor plugins, and more. Set the base URL, key,
and model name as above.

> [!TIP]
>
> Set `stream: true` for token streaming. See [Run inference](https://docs.valkyrieapp.azumo.com/guides/inference.md) for
> a streaming example and [Errors](https://docs.valkyrieapp.azumo.com/api-reference/errors.md) for handling failures.


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