# Opencode

[**Opencode**](https://opencode.ai/) is a powerful, open-source AI coding agent built specifically for the terminal, featuring a native, responsive, and themeable terminal user interface. **Opencode** offers developers terminal-based coding assistance, debugging, file management, and command execution — all within the CLI.<br>

This guide will walk you through the setup process and show you how to combine **Opencode** with **Cortecs** for enhanced productivity.

{% hint style="info" %}
*Before you begin: Make sure you have generated your Cortecs API key. If not, check out our* [*QuickStart*](https://docs.cortecs.ai/quickstart) *guide.*
{% endhint %}

## 1. Install Opencode

Run the following command in your terminal to install Opencode:

```apache
curl -fsSL https://opencode.ai/install | bash
```

For additional installation options, refer to the [Opencode documentation](https://opencode.ai/docs#install).

## 2. Connect to cortecs

Cortecs provides a **native integration** for Opencode:

1. Run the authentication command:

```bash
opencode auth login
```

2. Select **Cortecs** as the provider:

<figure><img src="/files/ZUkbKWqLgeAoa2BZZzDo" alt="" width="563"><figcaption></figcaption></figure>

3. Enter your **Cortecs API key** and press Enter:

<figure><img src="/files/l0vS35VSN1UWUcxhvlh4" alt="" width="563"><figcaption></figcaption></figure>

Your authentication is now complete :white\_check\_mark:.

## 3. Start using Opencode

1. Launch Opencode by typing `opencode` in your console:

<figure><img src="/files/mwJoxsOxi49UYs0zMEFE" alt="" width="563"><figcaption></figcaption></figure>

2. Once the Opencode terminal opens, start a new session using `/new`, then use `/models` to view and select a model:

<figure><img src="/files/q5iPsmvBR5U4SM1FDmJ7" alt="" width="563"><figcaption></figcaption></figure>

Choose the model you want to use and press Enter ✅.

> 💡 **Tip:** If you’re looking for a specific model, you can either:
>
> * Join the [Discord](https://discord.com/invite/bPFEFcWBhp) community 💬 and request it, or
> * Add it directly to the [Models.dev](https://github.com/sst/models.dev/tree/dev/providers/cortecs/models) open-source database in the Cortecs provider folder.

**You’re all set!** 🎉

You can now start a discussion with your AI agent!

<figure><img src="/files/MtuAHhmc3s0giarae34Q" alt="" width="563"><figcaption></figcaption></figure>

Enjoy the power of **Cortecs** and **Opencode**, explore different models, and share feedback with the community on [Discord](https://discord.com/invite/bPFEFcWBhp) 👩‍💻👨‍💻.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cortecs.ai/integration-examples/coding/opencode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
