> 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. 모델 목록에서 추가한 모델을 선택하여 사용합니다.
