> For the complete documentation index, see [llms.txt](https://runyourai.gitbook.io/userguide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://runyourai.gitbook.io/userguide/api/opencode.md).

# \[활용하기] OpenCode

### 사전 작업

* [API 라우터에서 API Key 발급](https://runyourai.gitbook.io/userguide/api/guide/get)
* [OpenCode 설치](https://opencode.ai/docs/ko#%EC%84%A4%EC%B9%98)

### 연동 하기

1. 아래 링크를 참고하여 OpenCode 설정 파일을 찾습니다.
   1. [\[OpenCode 문서\] Config](https://opencode.ai/docs/ko/config/)
2. OpenCode 설정 파일을 아래 안내에 따라 수정합니다.
   1. 사용하고자하는 AI Model을 [지원 목록](https://runyourai.gitbook.io/userguide/api/guide/models#runyour-api-router)에서 확인합니다.
   2. 아래 양식으로 OpenCode 설정 파일을 수정합니다.
      1. ```
         {
           "$schema": "https://opencode.ai/config.json",
           "provider": {
             "runyourai": {
               "npm": "@ai-sdk/openai",
               "options": {
                 "baseURL": "https://api.runyour.ai/v1",
                 "apiKey": <API 라우터에서 발급받은 API Key>
               },
               "models": {
                 <설정에서 사용하는 별칭>: {
                   "id": <지원 목록에서 확인한 모델 ID>,
                   "name": <표시할 모델 이름>
                 },
                 // 예시
                 "opus-4-7": {
                   "id": "anthropic/claude-opus-4-7",
                   "name": "Claude Opus 4.7"
                 }
               }
             }
           }
         }
         ```
3. OpenCode를 재시작합니다.
4. 모델 목록에서 추가한 모델을 선택하여 사용합니다.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://runyourai.gitbook.io/userguide/api/opencode.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
