|
| 1 | +# OpenChat Playground with Anthropic |
| 2 | + |
| 3 | +This page describes how to run OpenChat Playground (OCP) with [Anthropic models](https://docs.claude.com/en/docs/about-claude/models) integration. |
| 4 | + |
| 5 | +## Get the repository root |
| 6 | + |
| 7 | +1. Get the repository root. |
| 8 | + |
| 9 | + ```bash |
| 10 | + # bash/zsh |
| 11 | + REPOSITORY_ROOT=$(git rev-parse --show-toplevel) |
| 12 | + ``` |
| 13 | + |
| 14 | + ```powershell |
| 15 | + # PowerShell |
| 16 | + $REPOSITORY_ROOT = git rev-parse --show-toplevel |
| 17 | + ``` |
| 18 | + |
| 19 | +## Run on local machine |
| 20 | + |
| 21 | +1. Make sure you are at the repository root. |
| 22 | + |
| 23 | + ```bash |
| 24 | + cd $REPOSITORY_ROOT |
| 25 | + ``` |
| 26 | + |
| 27 | +1. Add Anthropic API Key for Claude connection. Make sure you should replace `{{ANTHROPIC_API_KEY}}` with your Anthropic API key. |
| 28 | + |
| 29 | + ```bash |
| 30 | + # bash/zsh |
| 31 | + dotnet user-secrets --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp \ |
| 32 | + set Anthropic:ApiKey "{{ANTHROPIC_API_KEY}}" |
| 33 | + ``` |
| 34 | + |
| 35 | + ```bash |
| 36 | + # PowerShell |
| 37 | + dotnet user-secrets --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp ` |
| 38 | + set Anthropic:ApiKey "{{ANTHROPIC_API_KEY}}" |
| 39 | + ``` |
| 40 | + |
| 41 | + > For more details about Anthropic API keys, refer to the doc, [Anthropic API Documentation](https://docs.anthropic.com/claude/reference/getting-started-with-the-api). |
| 42 | + |
| 43 | +1. Run the app. The default model OCP uses is [Claude Sonnet 4.5](https://www.anthropic.com/claude/sonnet). |
| 44 | + |
| 45 | + ```bash |
| 46 | + # bash/zsh |
| 47 | + dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- \ |
| 48 | + --connector-type Anthropic |
| 49 | + ``` |
| 50 | + |
| 51 | + ```powershell |
| 52 | + # PowerShell |
| 53 | + dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- ` |
| 54 | + --connector-type Anthropic |
| 55 | + ``` |
| 56 | + |
| 57 | + Alternatively, if you want to run with a different model, say [Claude Opus 4.1](http://www.anthropic.com/claude-opus-4-1-system-card), other than the default one, you can specify it as an argument: |
| 58 | + |
| 59 | + ```bash |
| 60 | + # bash/zsh |
| 61 | + dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- \ |
| 62 | + --connector-type Anthropic \ |
| 63 | + --model claude-opus-4-1 |
| 64 | + ``` |
| 65 | + |
| 66 | + ```powershell |
| 67 | + # PowerShell |
| 68 | + dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- ` |
| 69 | + --connector-type Anthropic ` |
| 70 | + --model claude-opus-4-1 |
| 71 | + ``` |
| 72 | + |
| 73 | + By default the app limits the model's response to [512 tokens](https://docs.claude.com/en/docs/about-claude/models/overview), other than the default one, you can specify it as an argument: |
| 74 | +
|
| 75 | + ```bash |
| 76 | + # bash/zsh |
| 77 | + dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- \ |
| 78 | + --connector-type Anthropic \ |
| 79 | + --max-tokens 2048 |
| 80 | + ``` |
| 81 | +
|
| 82 | + ```powershell |
| 83 | + # PowerShell |
| 84 | + dotnet run --project $REPOSITORY_ROOT/src/OpenChat.PlaygroundApp -- ` |
| 85 | + --connector-type Anthropic ` |
| 86 | + --max-tokens 2048 |
| 87 | + ``` |
| 88 | +
|
| 89 | +1. Open your web browser, navigate to `http://localhost:5280`, and enter prompts. |
| 90 | +
|
| 91 | +## Run in local container |
| 92 | +
|
| 93 | +1. Make sure you are at the repository root. |
| 94 | +
|
| 95 | + ```bash |
| 96 | + cd $REPOSITORY_ROOT |
| 97 | + ``` |
| 98 | +
|
| 99 | +1. Build a container. |
| 100 | +
|
| 101 | + ```bash |
| 102 | + docker build -f Dockerfile -t openchat-playground:latest . |
| 103 | + ``` |
| 104 | +
|
| 105 | +1. Get Anthropic API Key. |
| 106 | +
|
| 107 | + ```bash |
| 108 | + # bash/zsh |
| 109 | + API_KEY=$(dotnet user-secrets --project ./src/OpenChat.PlaygroundApp list --json | \ |
| 110 | + sed -n '/^\/\//d; p' | jq -r '."Anthropic:ApiKey"') |
| 111 | + ``` |
| 112 | +
|
| 113 | + ```bash |
| 114 | + # PowerShell |
| 115 | + $API_KEY = (dotnet user-secrets --project ./src/OpenChat.PlaygroundApp list --json | ` |
| 116 | + Select-String -NotMatch '^//(BEGIN|END)' | ConvertFrom-Json).'Anthropic:ApiKey' |
| 117 | + ``` |
| 118 | +
|
| 119 | +1. Run the app. The default model OCP uses is [Claude Sonnet 4.5](https://www.anthropic.com/claude/sonnet). |
| 120 | +
|
| 121 | + ```bash |
| 122 | + # bash/zsh - from locally built container |
| 123 | + docker run -i --rm -p 8080:8080 openchat-playground:latest --connector-type Anthropic \ |
| 124 | + --api-key $API_KEY |
| 125 | + ``` |
| 126 | +
|
| 127 | + ```powershell |
| 128 | + # PowerShell - from locally built container |
| 129 | + docker run -i --rm -p 8080:8080 openchat-playground:latest --connector-type Anthropic ` |
| 130 | + --api-key $API_KEY |
| 131 | + ``` |
| 132 | +
|
| 133 | + ```bash |
| 134 | + # bash/zsh - from GitHub Container Registry |
| 135 | + docker run -i --rm -p 8080:8080 ghcr.io/aliencube/open-chat-playground/openchat-playground:latest \ |
| 136 | + --connector-type Anthropic \ |
| 137 | + --api-key $API_KEY |
| 138 | + ``` |
| 139 | +
|
| 140 | + ```powershell |
| 141 | + # PowerShell - from GitHub Container Registry |
| 142 | + docker run -i --rm -p 8080:8080 ghcr.io/aliencube/open-chat-playground/openchat-playground:latest ` |
| 143 | + --connector-type Anthropic ` |
| 144 | + --api-key $API_KEY |
| 145 | + ``` |
| 146 | +
|
| 147 | + Alternatively, if you want to run with a different model, say [Claude Opus 4.1](http://www.anthropic.com/claude-opus-4-1-system-card), other than the default one, you can specify it as an argument: |
| 148 | +
|
| 149 | + ```bash |
| 150 | + # bash/zsh - from locally built container |
| 151 | + docker run -i --rm -p 8080:8080 openchat-playground:latest --connector-type Anthropic \ |
| 152 | + --api-key $API_KEY |
| 153 | + --model claude-opus-4-1 |
| 154 | + ``` |
| 155 | +
|
| 156 | + ```powershell |
| 157 | + # PowerShell - from locally built container |
| 158 | + docker run -i --rm -p 8080:8080 openchat-playground:latest --connector-type Anthropic ` |
| 159 | + --api-key $API_KEY |
| 160 | + --model claude-opus-4-1 |
| 161 | + ``` |
| 162 | +
|
| 163 | + ```bash |
| 164 | + # bash/zsh - from GitHub Container Registry |
| 165 | + docker run -i --rm -p 8080:8080 ghcr.io/aliencube/open-chat-playground/openchat-playground:latest \ |
| 166 | + --connector-type Anthropic \ |
| 167 | + --api-key $API_KEY |
| 168 | + --model claude-opus-4-1 |
| 169 | + ``` |
| 170 | +
|
| 171 | + ```powershell |
| 172 | + # PowerShell - from GitHub Container Registry |
| 173 | + docker run -i --rm -p 8080:8080 ghcr.io/aliencube/open-chat-playground/openchat-playground:latest ` |
| 174 | + --connector-type Anthropic ` |
| 175 | + --api-key $API_KEY |
| 176 | + --model claude-opus-4-1 |
| 177 | + ``` |
| 178 | +
|
| 179 | + By default the app limits the model's response to [512 tokens](https://docs.claude.com/en/docs/about-claude/models/overview), other than the default one, you can specify it as an argument: |
| 180 | + |
| 181 | + ```bash |
| 182 | + # bash/zsh - from locally built container |
| 183 | + docker run -i --rm -p 8080:8080 openchat-playground:latest --connector-type Anthropic \ |
| 184 | + --api-key $API_KEY |
| 185 | + --max-tokens 2048 |
| 186 | + ``` |
| 187 | + |
| 188 | + ```powershell |
| 189 | + # PowerShell - from locally built container |
| 190 | + docker run -i --rm -p 8080:8080 openchat-playground:latest --connector-type Anthropic ` |
| 191 | + --api-key $API_KEY |
| 192 | + --max-tokens 2048 |
| 193 | + ``` |
| 194 | +
|
| 195 | + ```bash |
| 196 | + # bash/zsh - from GitHub Container Registry |
| 197 | + docker run -i --rm -p 8080:8080 ghcr.io/aliencube/open-chat-playground/openchat-playground:latest \ |
| 198 | + --connector-type Anthropic \ |
| 199 | + --api-key $API_KEY |
| 200 | + --max-tokens 2048 |
| 201 | + ``` |
| 202 | +
|
| 203 | + ```powershell |
| 204 | + # PowerShell - from GitHub Container Registry |
| 205 | + docker run -i --rm -p 8080:8080 ghcr.io/aliencube/open-chat-playground/openchat-playground:latest ` |
| 206 | + --connector-type Anthropic ` |
| 207 | + --api-key $API_KEY |
| 208 | + --max-tokens 2048 |
| 209 | + ``` |
| 210 | +
|
| 211 | +1. Open your web browser, navigate to `http://localhost:8080`, and enter prompts. |
| 212 | +
|
| 213 | +## Run on Azure |
| 214 | +
|
| 215 | +1. Make sure you are at the repository root. |
| 216 | +
|
| 217 | + ```bash |
| 218 | + cd $REPOSITORY_ROOT |
| 219 | + ``` |
| 220 | +
|
| 221 | +1. Login to Azure. |
| 222 | +
|
| 223 | + ```bash |
| 224 | + azd auth login |
| 225 | + ``` |
| 226 | +
|
| 227 | +1. Check login status. |
| 228 | +
|
| 229 | + ```bash |
| 230 | + azd auth login --check-status |
| 231 | + ``` |
| 232 | +
|
| 233 | +1. Initialize `azd` template. |
| 234 | +
|
| 235 | + ```bash |
| 236 | + azd init |
| 237 | + ``` |
| 238 | +
|
| 239 | + > **NOTE**: You will be asked to provide environment name for provisioning. |
| 240 | +
|
| 241 | +1. Get Anthropic API Key. |
| 242 | +
|
| 243 | + ```bash |
| 244 | + # bash/zsh |
| 245 | + API_KEY=$(dotnet user-secrets --project ./src/OpenChat.PlaygroundApp list --json | \ |
| 246 | + sed -n '/^\/\//d; p' | jq -r '."Anthropic:ApiKey"') |
| 247 | + ``` |
| 248 | +
|
| 249 | + ```bash |
| 250 | + # PowerShell |
| 251 | + $API_KEY = (dotnet user-secrets --project ./src/OpenChat.PlaygroundApp list --json | ` |
| 252 | + Select-String -NotMatch '^//(BEGIN|END)' | ConvertFrom-Json).'Anthropic:ApiKey' |
| 253 | + ``` |
| 254 | + |
| 255 | +1. Set Anthropic API Key to azd environment variables. |
| 256 | + |
| 257 | + ```bash |
| 258 | + azd env set ANTHROPIC_API_KEY $API_KEY |
| 259 | + ``` |
| 260 | + |
| 261 | + The default model OCP uses is [Claude Sonnet 4.5](https://www.anthropic.com/claude/sonnet). If you want to run with a different model, say [Claude Opus 4.1](http://www.anthropic.com/claude-opus-4-1-system-card), other than the default one, add it to azd environment variables. |
| 262 | + |
| 263 | + ```bash |
| 264 | + azd env set ANTHROPIC_MODEL claude-opus-4-1 |
| 265 | + ``` |
| 266 | + |
| 267 | + By default the app limits the model's response to [512 tokens](https://docs.claude.com/en/docs/about-claude/models/overview), other than the default one, add it to azd environment variables. |
| 268 | + ```bash |
| 269 | + azd env set ANTHROPIC_MAX_TOKENS 2048 |
| 270 | + ``` |
| 271 | +
|
| 272 | +1. Set the connector type to `Anthropic`. |
| 273 | +
|
| 274 | + ```bash |
| 275 | + azd env set CONNECTOR_TYPE Anthropic |
| 276 | + ``` |
| 277 | +
|
| 278 | +1. Run the following commands in order to provision and deploy the app. |
| 279 | +
|
| 280 | + ```bash |
| 281 | + azd up |
| 282 | + ``` |
| 283 | +
|
| 284 | + > **NOTE**: You will be asked to provide Azure subscription and location for deployment. |
| 285 | +
|
| 286 | + Once deployed, you will be able to see the deployed OCP app URL. |
| 287 | +
|
| 288 | +1. Open your web browser, navigate to the OCP app URL, and enter prompts. |
| 289 | +
|
| 290 | +1. Clean up all the resources. |
| 291 | +
|
| 292 | + ```bash |
| 293 | + azd down --force --purge |
| 294 | + ``` |
0 commit comments