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

# OpenCode

> centralised cost monitoring for opencode

[OpenCode](https://opencode.ai) is a claude code alternative that has quickly gained in popularity and is recommended by many of the top thought leaders in the AI space

Using Prisma AIRS AI Gateway to track costs for OpenCode is simple and one step setup because the AI Gateway is openAI compatible.

# Setup

We use the [custom provider](https://opencode.ai/docs/providers/#custom-provider) option from opencode to integrate with the AI Gateway.

1. In your OpenCode settings (usually located at `~/.config/opencode/opencode.json` in macos, check [https://opencode.ai/docs/config/#locations](https://opencode.ai/docs/config/#locations)) configure the following:

```json theme={"system"}
 {
   "$schema": "https://opencode.ai/config.json",
   "provider": {
     "portkey": {
       "npm": "@ai-sdk/openai-compatible",
       "name": "Portkey",
       "options": {
         "baseURL": "https://aigw.portkey.ai/v1",
         "headers": {
             "Authorization": "Bearer YOUR_PORTKEY_API_KEY"
         }
       },
       "models": {
         "@your-integration-name/your-model-name": {
           "name": "gemini 2.5 flash enterprise team"
         }
       }
     }
   }
 }
```

here `your-integration-name` is the name of the integration you have configured in the AI Gateway and `your-model-name` is the name of the model you are using.

2. Start opencode and execute the `/connect` command and select the AI Gateway as the provider (if you are prompted for api key you can enter a dummy string)

3. You're all set. You can now track costs in Strata Cloud Manager and monitor your usage in real time.


## Related topics

- [Agentic Usage](/docs/aigw/api-reference/inference-api/agentic-usage.md)
- [Enterprise Gateway](/docs/aigw/changelog/enterprise.md)
- [OpenAI Codex](/docs/aigw/integrations/libraries/codex.md)
- [Coding Agents](/docs/aigw/product/coding-agent.md)
- [Roo Code](/docs/aigw/integrations/libraries/roo-code.md)
