File size: 56,828 Bytes
0dbc9de | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 | ---
title: プロバイダー
description: OpenCode で LLM プロバイダーを使用する。
---
import config from "../../../../config.mjs"
export const console = config.console
OpenCode は [AI SDK](https://ai-sdk.dev/) および [Models.dev](https://models.dev) を使用して **75 以上の LLM プロバイダー** をサポートし、ローカルモデルの実行をサポートします。
プロバイダーを追加するには、次のことを行う必要があります。
1. `/connect` コマンドを使用して、プロバイダーの API キーを追加します。
2. OpenCode 設定でプロバイダーを構成します。
---
### 認証情報
`/connect` コマンドを使用してプロバイダーの API キーを追加すると、それらは保存されます
`~/.local/share/opencode/auth.json`で。
---
### 設定
OpenCode の `provider` セクションを通じてプロバイダーをカスタマイズできます。
config.
---
#### Base URL
`baseURL` オプションを設定することで、任意のプロバイダーのベース URL をカスタマイズできます。これは、プロキシサービスまたはカスタムエンドポイントを使用する場合に便利です。
```json title="opencode.json" {6}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"anthropic": {
"options": {
"baseURL": "https://api.anthropic.com/v1"
}
}
}
}
```
---
## OpenCode Zen
OpenCode Zen は、OpenCode チームが提供するモデルのリストです。
OpenCode で適切に動作することがテストおよび検証されています。 [詳細はこちら](/docs/zen)。
:::tip
初めての方は、OpenCode Zen から始めることをお勧めします。
:::
1. TUI で `/connect` コマンドを実行し、`OpenCode Zen` を選択して、[opencode.ai/zen](https://opencode.ai/zen) にアクセスします。
```txt
/connect
```
2. サインインし、お支払いの詳細を追加し、API キーをコピーします。
3. API キーを貼り付けます。
```txt
┌ API key
│
│
└ enter
```
4. TUI で `/models` を実行すると、推奨されるモデルのリストが表示されます。
```txt
/models
```
これは OpenCode の他のプロバイダーと同様に機能し、使用は完全にオプションです。
---
## OpenCode Go
OpenCode Go は、OpenCode チームによって提供される、人気のあるオープンコーディングモデルへの信頼性の高いアクセスを提供する低コストのサブスクリプションプランです。これらは OpenCode でうまく機能することがテストおよび検証されています。
1. TUI で `/connect` コマンドを実行し、`OpenCode Go` を選択して、[opencode.ai/zen](https://opencode.ai/zen) にアクセスします。
```txt
/connect
```
2. サインインし、お支払いの詳細を追加し、API キーをコピーします。
3. API キーを貼り付けます。
```txt
┌ API key
│
│
└ enter
```
4. TUI で `/models` を実行すると、推奨されるモデルのリストが表示されます。
```txt
/models
```
これは OpenCode の他のプロバイダーと同様に機能し、使用は完全にオプションです。
---
## ディレクトリ
いくつかのプロバイダーを詳しく見てみましょう。プロバイダーを追加したい場合は、
リストにある場合は、お気軽に PR を開いてください。
:::note
ここにプロバイダーが表示されない場合は、 PRを送信してください。
:::
---
### 302.AI
1. [302.AI console](https://302.ai/) に移動し、アカウントを作成し、API キーを生成します。
2. `/connect` コマンドを実行し、**302.AI** を検索します。
```txt
/connect
```
3. 302.AI API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行してモデルを選択します。
```txt
/models
```
---
### Amazon Bedrock
OpenCode で Amazon Bedrock を使用するには:
1. Amazon Bedrock コンソールの **モデルカタログ** に移動し、必要なモデルへのアクセスをリクエストします。
:::tip
Amazon Bedrock で必要なモデルにアクセスできる必要があります。
:::
2. **次のいずれかの方法を使用して認証を構成します**:
***
#### 環境変数 (クイックスタート)
opencode の実行中に次の環境変数のいずれかを設定します。
```bash
# オプション 1: AWS アクセスキーの使用
AWS_ACCESS_KEY_ID=XXX AWS_SECRET_ACCESS_KEY=YYY opencode
# オプション 2: 名前付き AWS プロファイルの使用
AWS_PROFILE=my-profile opencode
# オプション 3: Bedrock ベアラートークンの使用
AWS_BEARER_TOKEN_BEDROCK=XXX opencode
```
または、それらを bash プロファイルに追加します。
```bash title="~/.bash_profile"
export AWS_PROFILE=my-dev-profile
export AWS_REGION=us-east-1
```
***
#### 設定ファイル (推奨)
プロジェクト固有の設定または永続的な設定の場合は、`opencode.json` を使用します。
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"amazon-bedrock": {
"options": {
"region": "us-east-1",
"profile": "my-aws-profile"
}
}
}
}
```
**利用可能なオプション:**
- `region` - AWS リージョン (例: `us-east-1`、`eu-west-1`)
- `profile` - `~/.aws/credentials` からの AWS 名前付きプロファイル
- `endpoint` - VPC エンドポイントのカスタムエンドポイント URL (汎用 `baseURL` オプションのエイリアス)
:::tip
設定ファイルのオプションは環境変数より優先されます。
:::
***
#### 上級: VPC エンドポイント
Bedrock の VPC エンドポイントを使用している場合:
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"amazon-bedrock": {
"options": {
"region": "us-east-1",
"profile": "production",
"endpoint": "https://bedrock-runtime.us-east-1.vpce-xxxxx.amazonaws.com"
}
}
}
}
```
:::note
`endpoint` オプションは、AWS 固有の用語を使用した汎用の `baseURL` オプションのエイリアスです。 `endpoint` と `baseURL` の両方が指定された場合は、`endpoint` が優先されます。
:::
***
#### 認証方法
- **`AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY`**: IAM ユーザーを作成し、AWS コンソールでアクセスキーを生成します
- **`AWS_PROFILE`**: `~/.aws/credentials` の名前付きプロファイルを使用します。最初に `aws configure --profile my-profile` または `aws sso login` を設定します
- **`AWS_BEARER_TOKEN_BEDROCK`**: Amazon Bedrock コンソールから長期 API キーを生成します
- **`AWS_WEB_IDENTITY_TOKEN_FILE` / `AWS_ROLE_ARN`**: EKS IRSA (サービスアカウントの IAM ロール) または OIDC フェデレーションを備えた他の Kubernetes 環境の場合。これらの環境変数は、サービスアカウントアノテーションを使用するときに Kubernetes によって自動的に挿入されます。
***
#### 認証の優先順位
Amazon Bedrock は次の認証優先度を使用します。
1. **ベアラー トークン** - `AWS_BEARER_TOKEN_BEDROCK` 環境変数または `/connect` コマンドからのトークン
2. **AWS 認証情報チェーン** - プロファイル、アクセスキー、共有認証情報、IAM ロール、Web ID トークン (EKS IRSA)、インスタンスメタデータ
:::note
ベアラー トークンが (`/connect` または `AWS_BEARER_TOKEN_BEDROCK` 経由で) 設定されると、設定されたプロファイルを含むすべての AWS 認証情報方法よりも優先されます。
:::
3. `/models` コマンドを実行して、必要なモデルを選択します。
```txt
/models
```
:::note
カスタム推論プロファイルの場合、キーでモデルとプロバイダー名を使用し、`id` プロパティを arn に設定します。これにより、正しいキャッシュが保証されます。
:::
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"amazon-bedrock": {
// ...
"models": {
"anthropic-claude-sonnet-4.5": {
"id": "arn:aws:bedrock:us-east-1:xxx:application-inference-profile/yyy"
}
}
}
}
}
```
---
### Anthropic
1. サインアップしたら、`/connect` コマンドを実行し、[Anthropic] を選択します。
```txt
/connect
```
2. ここで **Claude Pro/Max** オプションを選択すると、ブラウザが開きます
そして認証を求められます。
```txt
┌ Select auth method
│
│ Claude Pro/Max
│ Create an API Key
│ Manually enter API Key
└
```
3. これで、`/models` コマンドを使用すると、すべての Anthropic モデルが利用できるようになります。
```txt
/models
```
:::info
OpenCode での Claude Pro/Max サブスクリプションの使用は、[Anthropic](https://anthropic.com) によって正式に許可されていませんが、一般的に機能します。
:::
##### APIキーの使用
Pro/Max サブスクリプションをお持ちでない場合は、[**API キーの作成**] を選択することもできます。また、ブラウザが開き、Anthropic にログインするよう求められ、ターミナルに貼り付けるコードが表示されます。
または、すでに API キーをお持ちの場合は、[**API キーを手動で入力**] を選択してターミナルに貼り付けることができます。
---
### Atomic Chat
opencode は、OpenAI 互換の API サーバーの背後でローカル LLM を実行するデスクトップアプリケーション [Atomic Chat](https://atomic.chat) 経由でローカルモデルを使うように設定できます(デフォルトのエンドポイントは `http://127.0.0.1:1337/v1`)。
```json title="opencode.json" "atomic-chat" {5, 6, 8, 10-14}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"atomic-chat": {
"npm": "@ai-sdk/openai-compatible",
"name": "Atomic Chat (local)",
"options": {
"baseURL": "http://127.0.0.1:1337/v1"
},
"models": {
"<your-model-id>": {
"name": "<your-model-name>"
}
}
}
}
}
```
この例では:
- `atomic-chat` はカスタムプロバイダー ID です。任意の文字列を指定できます。
- `npm` はこのプロバイダーに使用するパッケージを指定します。ここでは、任意の OpenAI 互換 API に対して `@ai-sdk/openai-compatible` を使用しています。
- `name` は UI に表示されるプロバイダー名です。
- `options.baseURL` はローカルサーバーのエンドポイントです。Atomic Chat のセットアップに合わせてホストとポートを変更してください。
- `models` はモデル ID と表示名のマップです。各 ID は `GET /v1/models` が返す `id` と一致する必要があります。Atomic Chat に現在ロードされている ID の一覧は `curl http://127.0.0.1:1337/v1/models` を実行して確認できます。
:::tip
ツール呼び出しがうまく動作しない場合は、ツール呼び出しに強いロード済みモデル(例えば Qwen-Coder や DeepSeek-Coder のバリアント)を選択してください。
:::
---
### Azure OpenAI
:::note
「申し訳ありませんが、そのリクエストには対応できません」エラーが発生した場合は、Azure リソースのコンテンツフィルターを **DefaultV2** から **Default** に変更してみてください。
:::
1. [Azure portal](https://portal.azure.com/) に移動し、**Azure OpenAI** リソースを作成します。必要なものは次のとおりです。
- **リソース名**: これは API エンドポイント (`https://RESOURCE_NAME.openai.azure.com/`) の一部になります。
- **API キー**: リソースの `KEY 1` または `KEY 2` のいずれか
2. [Azure AI Foundry](https://ai.azure.com/) に移動し、モデルをデプロイします。
:::note
OpenCode が正しく動作するには、デプロイメント名がモデル名と一致する必要があります。
:::
3. `/connect` コマンドを実行し、**Azure** を検索します。
```txt
/connect
```
4. API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
5. リソース名を環境変数として設定します。
```bash
AZURE_RESOURCE_NAME=XXX opencode
```
または、bash プロファイルに追加します。
```bash title="~/.bash_profile"
export AZURE_RESOURCE_NAME=XXX
```
6. `/models` コマンドを実行して、デプロイされたモデルを選択します。
```txt
/models
```
---
### Azure Cognitive Services
1. [Azure portal](https://portal.azure.com/) に移動し、**Azure OpenAI** リソースを作成します。必要なものは次のとおりです。
- **リソース名**: これは API エンドポイント (`https://AZURE_COGNITIVE_SERVICES_RESOURCE_NAME.cognitiveservices.azure.com/`) の一部になります。
- **API キー**: リソースの `KEY 1` または `KEY 2` のいずれか
2. [Azure AI Foundry](https://ai.azure.com/) に移動し、モデルをデプロイします。
:::note
OpenCode が正しく動作するには、デプロイメント名がモデル名と一致する必要があります。
:::
3. `/connect` コマンドを実行し、**Azure Cognitive Services** を検索します。
```txt
/connect
```
4. API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
5. リソース名を環境変数として設定します。
```bash
AZURE_COGNITIVE_SERVICES_RESOURCE_NAME=XXX opencode
```
または、bash プロファイルに追加します。
```bash title="~/.bash_profile"
export AZURE_COGNITIVE_SERVICES_RESOURCE_NAME=XXX
```
6. `/models` コマンドを実行して、デプロイされたモデルを選択します。
```txt
/models
```
---
### Baseten
1. [Baseten](https://app.baseten.co/) に移動し、アカウントを作成し、API キーを生成します。
2. `/connect` コマンドを実行し、**Baseten** を検索します。
```txt
/connect
```
3. Baseten API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行してモデルを選択します。
```txt
/models
```
---
### Cerebras
1. [Cerebras console](https://inference.cerebras.ai/) に移動し、アカウントを作成し、API キーを生成します。
2. `/connect` コマンドを実行し、**Cerebras** を検索します。
```txt
/connect
```
3. Cerebras API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、_Qwen 3 Coder 480B_ のようなモデルを選択します。
```txt
/models
```
---
### Cloudflare AI Gateway
Cloudflare AI Gatewayを使用すると、統合エンドポイントを通じてOpenAI、Anthropic、Workers AIなどのモデルにアクセスできます。 [Unified Billing](https://developers.cloudflare.com/ai-gateway/features/unified-billing/) を使用すると、プロバイダーごとに個別の API キーは必要ありません。
1. [Cloudflare ダッシュボード ](https://dash.cloudflare.com/) に移動し、**AI** > **AI ゲートウェイ** に移動し、新しいゲートウェイを作成します。
2. アカウント ID とゲートウェイ ID を環境変数として設定します。
```bash title="~/.bash_profile"
export CLOUDFLARE_ACCOUNT_ID=your-32-character-account-id
export CLOUDFLARE_GATEWAY_ID=your-gateway-id
```
3. `/connect` コマンドを実行し、**Cloudflare AI Gateway** を検索します。
```txt
/connect
```
4. Cloudflare API トークンを入力します。
```txt
┌ API key
│
│
└ enter
```
または環境変数として設定します。
```bash title="~/.bash_profile"
export CLOUDFLARE_API_TOKEN=your-api-token
```
5. `/models` コマンドを実行してモデルを選択します。
```txt
/models
```
OpenCode 設定を通じてモデルを追加することもできます。
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"cloudflare-ai-gateway": {
"models": {
"openai/gpt-4o": {},
"anthropic/claude-sonnet-4": {}
}
}
}
}
```
---
### Cortecs
1. [Cortecs console](https://cortecs.ai/) に移動し、アカウントを作成し、API キーを生成します。
2. `/connect` コマンドを実行し、**Cortecs** を検索します。
```txt
/connect
```
3. Cortecs API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、_Kimi K2 Instruct_ のようなモデルを選択します。
```txt
/models
```
---
### DeepSeek
1. [DeepSeek コンソール ](https://platform.deepseek.com/) に移動し、アカウントを作成し、**新しい API キーの作成** をクリックします。
2. `/connect` コマンドを実行し、**DeepSeek** を検索します。
```txt
/connect
```
3. DeepSeek API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、_DeepSeek V4 Pro_ のような DeepSeek モデルを選択します。
```txt
/models
```
---
### Deep Infra
1. [Deep Infra ダッシュボード](https://deepinfra.com/dash) に移動し、アカウントを作成し、API キーを生成します。
2. `/connect` コマンドを実行し、**Deep Infra** を検索します。
```txt
/connect
```
3. Deep Infra API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行してモデルを選択します。
```txt
/models
```
---
### FrogBot
1. [ファームウェアダッシュボード](https://app.frogbot.ai/signup) に移動し、アカウントを作成し、API キーを生成します。
2. `/connect` コマンドを実行し、**ファームウェア**を検索します。
```txt
/connect
```
3. ファームウェア API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行してモデルを選択します。
```txt
/models
```
---
### Fireworks AI
1. [Fireworks AI コンソール ](https://app.fireworks.ai/) に移動し、アカウントを作成し、**API キーの作成** をクリックします。
2. `/connect` コマンドを実行し、**Fireworks AI** を検索します。
```txt
/connect
```
3. Fireworks AI API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、_Kimi K2 Instruct_ のようなモデルを選択します。
```txt
/models
```
---
### GitLab Duo
GitLab Duo は、GitLab の Anthropic プロキシを介したネイティブツール呼び出し機能を備えた AI を活用したエージェントチャットを提供します。
1. `/connect` コマンドを実行し、GitLab を選択します。
```txt
/connect
```
2. 認証方法を選択してください:
```txt
┌ Select auth method
│
│ OAuth (Recommended)
│ Personal Access Token
└
```
#### OAuthの使用(推奨)
**OAuth** を選択すると、認証のためにブラウザが開きます。
#### パーソナルアクセストークンの使用
1. [GitLab ユーザー設定 > アクセス Tokens](https://gitlab.com/-/user_settings/personal_access_tokens) に移動します。
2. **新しいトークンを追加** をクリックします
3. 名前: `OpenCode`、スコープ: `api`
4. トークンをコピーします(`glpat-`で始まる)
5. ターミナルに入力してください
6. `/models` コマンドを実行して、利用可能なモデルを確認します。
```txt
/models
```
---
### STACKIT
STACKIT AI Model Serving は、Llama、Mistral、Qwen などの LLM に焦点を当て、ヨーロッパのインフラストラクチャでの最大限のデータ主権を備えた、AI モデル用の完全に管理された主権ホスティング環境を提供します。
1. [STACKIT Portal](https://portal.stackit.cloud) に移動し、**AI Model Serving** に移動して、プロジェクトの認証トークンを作成します。
:::tip
認証トークンを作成する前に、STACKIT 顧客アカウント、ユーザーアカウント、およびプロジェクトが必要です。
:::
2. `/connect` コマンドを実行し、**STACKIT** を検索します。
```txt
/connect
```
3. STACKIT AI Model Serving 認証トークンを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、_Qwen3-VL 235B_ や _Llama 3.3 70B_ などの利用可能なモデルから選択します。
```txt
/models
```
3 つの Claude ベースのモデルが利用可能です。
- **duo-chat-haiku-4-5** (デフォルト) - 素早いタスクに対する素早い応答
- **duo-chat-sonnet-4-5** - ほとんどのワークフローでバランスの取れたパフォーマンス
- **duo-chat-opus-4-5** - 複雑な分析に最も適した能力
:::note
必要がない場合は、「GITLAB_TOKEN」環境変数を指定することもできます。
トークンを OpenCode 認証ストレージに保存します。
:::
##### 自己ホスト型 GitLab
:::note[コンプライアンスメモ]
OpenCode は、セッションタイトルの生成などの一部の AI タスクに小規模なモデルを使用します。
デフォルトでは、Zen によってホストされる gpt-5-nano を使用するように構成されています。 OpenCode をロックするには
自分の GitLab でホストされているインスタンスのみを使用するには、次の行を
`opencode.json` ファイル。セッション共有を無効にすることもお勧めします。
```json
{
"small_model": "gitlab/duo-chat-haiku-4-5",
"share": "disabled"
}
```
:::
セルフホスト型 GitLab インスタンスの場合:
```bash
export GITLAB_INSTANCE_URL=https://gitlab.company.com
export GITLAB_TOKEN=glpat-...
```
インスタンスがカスタム AI ゲートウェイを実行している場合:
```bash
GITLAB_AI_GATEWAY_URL=https://ai-gateway.company.com
```
または、bash プロファイルに追加します。
```bash title="~/.bash_profile"
export GITLAB_INSTANCE_URL=https://gitlab.company.com
export GITLAB_AI_GATEWAY_URL=https://ai-gateway.company.com
export GITLAB_TOKEN=glpat-...
```
:::note
GitLab 管理者は以下を有効にする必要があります。
1. [Duo Agent Platform](https://docs.gitlab.com/user/duo_agent_platform/turn_on_off/) (ユーザー、グループ、またはインスタンス用)
2. 機能フラグ (Rails コンソール経由):
- `agent_platform_claude_code`
- `third_party_agents_enabled`
:::
##### セルフホスト型インスタンスの OAuth
自己ホスト型インスタンスで Oauth を機能させるには、以下を作成する必要があります。
新しいアプリケーション ([設定] → [アプリケーション]) で、
コールバック URL `http://127.0.0.1:8080/callback` と次のスコープ:
- api (あなたの代わりに API にアクセスします)
- read_user (個人情報の読み取り)
- read_repository (リポジトリへの読み取り専用アクセスを許可します)
次に、アプリケーション ID を環境変数として公開します。
```bash
export GITLAB_OAUTH_CLIENT_ID=your_application_id_here
```
詳細については、[opencode-gitlab-auth](https://www.npmjs.com/package/opencode-gitlab-auth) ホームページ。
##### 設定
`opencode.json` を通じてカスタマイズします。
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"gitlab": {
"options": {
"instanceUrl": "https://gitlab.com"
}
}
}
}
```
##### GitLab API ツール (オプションですが強く推奨)
GitLab ツール (マージリクエスト、問題、パイプライン、CI/CD など) にアクセスするには:
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-gitlab-plugin"]
}
```
このプラグインは、MR レビュー、問題追跡、パイプライン監視などを含む、包括的な GitLab リポジトリ管理機能を提供します。
---
### GitHub Copilot
GitHub Copilot サブスクリプションを OpenCode で使用するには:
:::note
一部のモデルでは [Pro+] が必要になる場合があります。
subscription](https://github.com/features/copilot/plans) を使用します。
一部のモデルは、[GitHub Copilot settings](https://docs.github.com/en/copilot/how-tos/use-ai-models/configure-access-to-ai-models#setup-for-individual-use) で構成する必要があります。
:::
1. `/connect` コマンドを実行し、GitHub Copilot を検索します。
```txt
/connect
```
2. [github.com/login/device](https://github.com/login/device) に移動し、コードを入力します。
```txt
┌ Login with GitHub Copilot
│
│ https://github.com/login/device
│
│ Enter code: 8F43-6FCF
│
│
└ Waiting for authorization...
```
3. 次に、`/models` コマンドを実行して、必要なモデルを選択します。
```txt
/models
```
---
### Google Vertex AI
OpenCode で Google Vertex AI を使用するには:
1. Google Cloud Console の **Model Garden** に移動し、
お住まいの地域で利用可能なモデル。
:::note
Vertex AI API が有効になっている Google Cloud プロジェクトが必要です。
:::
2. 必要な環境変数を設定します。
- `GOOGLE_CLOUD_PROJECT`: Google Cloud プロジェクト ID
- `VERTEX_LOCATION` (オプション): Vertex AI の領域 (デフォルトは `global`)
- 認証 (1 つ選択):
- `GOOGLE_APPLICATION_CREDENTIALS`: サービスアカウントの JSON キーファイルへのパス
- gcloud CLI を使用して認証する: `gcloud auth application-default login`
opencode の実行中に設定します。
```bash
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json GOOGLE_CLOUD_PROJECT=your-project-id opencode
```
または、それらを bash プロファイルに追加します。
```bash title="~/.bash_profile"
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
export GOOGLE_CLOUD_PROJECT=your-project-id
export VERTEX_LOCATION=global
```
:::tip
`global` 領域は、追加コストなしで可用性を向上させ、エラーを削減します。データ常駐要件には、リージョンエンドポイント (`us-central1` など) を使用します。 [詳細はこちら](https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/use-partner-models#regional_and_global_endpoints)
:::
3. `/models` コマンドを実行して、必要なモデルを選択します。
```txt
/models
```
---
### Groq
1. [Groq console](https://console.groq.com/) に移動し、[**API キーの作成**] をクリックして、キーをコピーします。
2. `/connect` コマンドを実行し、Groq を検索します。
```txt
/connect
```
3. プロバイダーの API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、必要なものを選択します。
```txt
/models
```
---
### Hugging Face
[Hugging Face Inference Provider](https://huggingface.co/docs/inference-providers) は、17 を超えるプロバイダーがサポートするオープンモデルへのアクセスを提供します。
1. [Hugging Face settings](https://huggingface.co/settings/tokens/new?ownUserPermissions=inference.serverless.write&tokenType=fineGrained) に移動して、推論プロバイダーを呼び出す権限を持つトークンを作成します。
2. `/connect` コマンドを実行し、**Hugging Face** を検索します。
```txt
/connect
```
3. Hugging Face トークンを入力してください。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、_Kimi-K2-Instruct_ や _GLM-4.6_ などのモデルを選択します。
```txt
/models
```
---
### Helicone
[Helicone](https://helicone.ai) は、AI アプリケーションのロギング、監視、分析を提供する LLM 可観測性プラットフォームです。 Helicone AI ゲートウェイは、モデルに基づいてリクエストを適切なプロバイダーに自動的にルーティングします。
1. [Helicone](https://helicone.ai) に移動し、アカウントを作成し、ダッシュボードから API キーを生成します。
2. `/connect` コマンドを実行し、**Helicone** を検索します。
```txt
/connect
```
3. Helicone API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行してモデルを選択します。
```txt
/models
```
その他のプロバイダーや、キャッシュやレート制限などの高度な機能については、[Helicone ドキュメント](https://docs.helicone.ai).
#### オプションの設定
OpenCode を通じて自動的に構成されていない Helicone の機能またはモデルを見つけた場合は、いつでも自分で構成できます。
これは [Helicone のモデルディレクトリ](https://helicone.ai/models) です。追加するモデルの ID を取得するためにこれが必要になります。
```jsonc title="~/.config/opencode/opencode.jsonc"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"helicone": {
"npm": "@ai-sdk/openai-compatible",
"name": "Helicone",
"options": {
"baseURL": "https://ai-gateway.helicone.ai",
},
"models": {
"gpt-4o": {
// Model ID (from Helicone's model directory page)
"name": "GPT-4o", // Your own custom name for the model
},
"claude-sonnet-4-20250929": {
"name": "Claude Sonnet 4",
},
},
},
},
}
```
#### カスタムヘッダー
Helicone は、キャッシュ、ユーザー追跡、セッション管理などの機能のカスタムヘッダーをサポートしています。 `options.headers` を使用してプロバイダー設定に追加します。
```jsonc title="~/.config/opencode/opencode.jsonc"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"helicone": {
"npm": "@ai-sdk/openai-compatible",
"name": "Helicone",
"options": {
"baseURL": "https://ai-gateway.helicone.ai",
"headers": {
"Helicone-Cache-Enabled": "true",
"Helicone-User-Id": "opencode",
},
},
},
},
}
```
##### セッション追跡
Helicone の [Sessions](https://docs.helicone.ai/features/sessions) 機能を使用すると、関連する LLM リクエストをグループ化できます。 [opencode-helicone-session](https://github.com/H2Shami/opencode-helicone-session) プラグインを使用して、各 OpenCode 会話を Helicone のセッションとして自動的に記録します。
```bash
npm install -g opencode-helicone-session
```
それを設定に追加します。
```json title="opencode.json"
{
"plugin": ["opencode-helicone-session"]
}
```
プラグインは、リクエストに `Helicone-Session-Id` ヘッダーと `Helicone-Session-Name` ヘッダーを挿入します。 Helicone のセッションページでは、OpenCode の各会話が個別のセッションとしてリストされています。
##### 一般的なヘリコーンヘッダー
| ヘッダー | 説明 |
| -------------------------- | ---------------------------------------------------------------------- |
| `Helicone-Cache-Enabled` | 応答キャッシュを有効にする (`true`/`false`) |
| `Helicone-User-Id` | ユーザーごとにメトリクスを追跡する |
| `Helicone-Property-[Name]` | カスタムプロパティを追加します (例: `Helicone-Property-Environment`)。 |
| `Helicone-Prompt-Id` | リクエストをプロンプトバージョンに関連付ける |
利用可能なすべてのヘッダーについては、[Helicone Header Directory](https://docs.helicone.ai/helicone-headers/header-directory) を参照してください。
---
### llama.cpp
[llama.cpp の s](https://github.com/ggml-org/llama.cpp) llama-server ユーティリティ] を通じて、ローカルモデルを使用するように opencode を構成できます。
```json title="opencode.json" "llama.cpp" {5, 6, 8, 10-15}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"llama.cpp": {
"npm": "@ai-sdk/openai-compatible",
"name": "llama-server (local)",
"options": {
"baseURL": "http://127.0.0.1:8080/v1"
},
"models": {
"qwen3-coder:a3b": {
"name": "Qwen3-Coder: a3b-30b (local)",
"limit": {
"context": 128000,
"output": 65536
}
}
}
}
}
}
```
この例では:
- `llama.cpp` はカスタムプロバイダー ID です。これには任意の文字列を指定できます。
- `npm` は、このプロバイダーに使用するパッケージを指定します。ここで、`@ai-sdk/openai-compatible` は OpenAI 互換 API に使用されます。
- `name` は、UI でのプロバイダーの表示名です。
- `options.baseURL` はローカルサーバーのエンドポイントです。
- `models` は、モデル ID とその設定のマップです。機種選択リストに機種名が表示されます。
---
### IO.NET
IO.NET は、さまざまなユースケースに最適化された 17 のモデルを提供します。
1. [IO.NET console](https://ai.io.net/) に移動し、アカウントを作成し、API キーを生成します。
2. `/connect` コマンドを実行し、**IO.NET** を検索します。
```txt
/connect
```
3. IO.NET API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行してモデルを選択します。
```txt
/models
```
---
### LM Studio
LM Studio を通じてローカルモデルを使用するように opencode を構成できます。
```json title="opencode.json" "lmstudio" {5, 6, 8, 10-14}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"lmstudio": {
"npm": "@ai-sdk/openai-compatible",
"name": "LM Studio (local)",
"options": {
"baseURL": "http://127.0.0.1:1234/v1"
},
"models": {
"google/gemma-3n-e4b": {
"name": "Gemma 3n-e4b (local)"
}
}
}
}
}
```
この例では:
- `lmstudio` はカスタムプロバイダー ID です。これには任意の文字列を指定できます。
- `npm` は、このプロバイダーに使用するパッケージを指定します。ここで、`@ai-sdk/openai-compatible` は OpenAI 互換 API に使用されます。
- `name` は、UI でのプロバイダーの表示名です。
- `options.baseURL` はローカルサーバーのエンドポイントです。
- `models` は、モデル ID とその設定のマップです。機種選択リストに機種名が表示されます。
---
### Moonshot AI
Moonshot AI の Kim K2 を使用するには:
1. [Moonshot AI console](https://platform.moonshot.ai/console) に移動し、アカウントを作成し、[**API キーの作成**] をクリックします。
2. `/connect` コマンドを実行し、**Moonshot AI** を検索します。
```txt
/connect
```
3. Moonshot API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、_Kimi K2_ を選択します。
```txt
/models
```
---
### MiniMax
1. [MiniMax API Console](https://platform.minimax.io/login) に移動し、アカウントを作成し、API キーを生成します。
2. `/connect` コマンドを実行し、**MiniMax** を検索します。
```txt
/connect
```
3. MiniMax API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、_M2.1_ のようなモデルを選択します。
```txt
/models
```
---
### Nebius Token Factory
1. [Nebius Token Factory console](https://tokenfactory.nebius.com/) に移動し、アカウントを作成し、[**キーの追加**] をクリックします。
2. `/connect` コマンドを実行し、**Nebius Token Factory** を検索します。
```txt
/connect
```
3. Nebius Token Factory API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、_Kimi K2 Instruct_ のようなモデルを選択します。
```txt
/models
```
---
### Ollama
Ollama を通じてローカルモデルを使用するように opencode を構成できます。
:::tip
Ollama は OpenCode 用に自動的に構成できます。詳細については、[Ollama 統合 docs](https://docs.ollama.com/integrations/opencode)」を参照してください。
:::
```json title="opencode.json" "ollama" {5, 6, 8, 10-14}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ollama": {
"npm": "@ai-sdk/openai-compatible",
"name": "Ollama (local)",
"options": {
"baseURL": "http://localhost:11434/v1"
},
"models": {
"llama2": {
"name": "Llama 2"
}
}
}
}
}
```
この例では:
- `ollama` はカスタムプロバイダー ID です。これには任意の文字列を指定できます。
- `npm` は、このプロバイダーに使用するパッケージを指定します。ここで、`@ai-sdk/openai-compatible` は OpenAI 互換 API に使用されます。
- `name` は、UI でのプロバイダーの表示名です。
- `options.baseURL` はローカルサーバーのエンドポイントです。
- `models` は、モデル ID とその設定のマップです。機種選択リストに機種名が表示されます。
:::tip
ツール呼び出しが機能しない場合は、Ollama の `num_ctx` を増やしてみてください。 16k〜32kあたりから始めてください。
:::
---
### Ollama Cloud
OpenCode で Ollama Cloud を使用するには:
1. [https://ollama.com/](https://ollama.com/) にアクセスしてサインインするか、アカウントを作成します。
2. [**設定**] > [キー**] に移動し、[**API キーの追加**] をクリックして新しい API キーを生成します。
3. OpenCode で使用するために API キーをコピーします。
4. `/connect` コマンドを実行し、**Ollama Cloud** を検索します。
```txt
/connect
```
5. Ollama Cloud API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
6. **重要**: OpenCode でクラウドモデルを使用する前に、モデル情報をローカルに取得する必要があります。
```bash
ollama pull gpt-oss:20b-cloud
```
7. `/models` コマンドを実行して、Ollama Cloud モデルを選択します。
```txt
/models
```
---
### OpenAI
[ChatGPT Plus または Pro](https://chatgpt.com/pricing) にサインアップすることをお勧めします。
1. サインアップしたら、`/connect` コマンドを実行し、OpenAI を選択します。
```txt
/connect
```
2. ここで **ChatGPT Plus/Pro** オプションを選択すると、ブラウザが開きます。
そして認証を求められます。
```txt
┌ Select auth method
│
│ ChatGPT Plus/Pro
│ Manually enter API Key
└
```
3. これで、`/models` コマンドを使用すると、すべての OpenAI モデルが利用できるようになります。
```txt
/models
```
##### APIキーの使用
すでに API キーをお持ちの場合は、**API キーを手動で入力** を選択し、ターミナルに貼り付けることができます。
---
### OpenCode Zen
OpenCode Zen は、OpenCode チームによって提供される、テストおよび検証されたモデルのリストです。 [詳細はこちら](/docs/zen)。
1. **<a href={console}>OpenCode Zen</a>** にサインインし、**API キーの作成** をクリックします。
2. `/connect` コマンドを実行し、**OpenCode Zen** を検索します。
```txt
/connect
```
3. OpenCode API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、_Qwen 3 Coder 480B_ のようなモデルを選択します。
```txt
/models
```
---
### OpenRouter
1. [OpenRouter ダッシュボード](https://openrouter.ai/settings/keys) に移動し、[**API キーの作成**] をクリックして、キーをコピーします。
2. `/connect` コマンドを実行し、OpenRouter を検索します。
```txt
/connect
```
3. プロバイダーの API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. 多くの OpenRouter モデルはデフォルトでプリロードされており、`/models` コマンドを実行して必要なモデルを選択します。
```txt
/models
```
OpenCode 設定を通じて追加のモデルを追加することもできます。
```json title="opencode.json" {6}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openrouter": {
"models": {
"somecoolnewmodel": {}
}
}
}
}
```
5. OpenCode 設定を通じてカスタマイズすることもできます。プロバイダーを指定する例を次に示します。
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openrouter": {
"models": {
"moonshotai/kimi-k2": {
"options": {
"provider": {
"order": ["baseten"],
"allow_fallbacks": false
}
}
}
}
}
}
}
```
---
### SAP AI Core
SAP AI コアは、統合プラットフォームを通じて、OpenAI、Anthropic、Google、Amazon、Meta、Mistral、AI21 の 40 以上のモデルへのアクセスを提供します。
1. [SAP BTP Cockpit](https://account.hana.ondemand.com/) に移動し、SAP AI コアサービスインスタンスに移動して、サービスキーを作成します。
:::tip
サービスキーは、`clientid`、`clientsecret`、`url`、および `serviceurls.AI_API_URL` を含む JSON オブジェクトです。 AI コアインスタンスは、BTP コックピットの **サービス** > **インスタンスとサブスクリプション** で見つかります。
:::
2. `/connect` コマンドを実行し、**SAP AI Core** を検索します。
```txt
/connect
```
3. サービスキーの JSON を入力します。
```txt
┌ Service key
│
│
└ enter
```
または、`AICORE_SERVICE_KEY` 環境変数を設定します。
```bash
AICORE_SERVICE_KEY='{"clientid":"...","clientsecret":"...","url":"...","serviceurls":{"AI_API_URL":"..."}}' opencode
```
または、bash プロファイルに追加します。
```bash title="~/.bash_profile"
export AICORE_SERVICE_KEY='{"clientid":"...","clientsecret":"...","url":"...","serviceurls":{"AI_API_URL":"..."}}'
```
4. 必要に応じて、デプロイメント ID とリソースグループを設定します。
```bash
AICORE_DEPLOYMENT_ID=your-deployment-id AICORE_RESOURCE_GROUP=your-resource-group opencode
```
:::note
これらの設定はオプションであり、SAP AI コアのセットアップに従って構成する必要があります。
:::
5. `/models` コマンドを実行して、40 以上の利用可能なモデルから選択します。
```txt
/models
```
---
### OVHcloud AI Endpoints
1. [OVHcloud パネル](https://ovh.com/manager) に移動します。 `Public Cloud` セクション、`AI & Machine Learning` > `AI Endpoints` に移動し、`API Keys` タブで **新しい API キーの作成** をクリックします。
2. `/connect` コマンドを実行し、**OVHcloud AI エンドポイント**を検索します。
```txt
/connect
```
3. OVHcloud AI エンドポイント API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、_gpt-oss-120b_ のようなモデルを選択します。
```txt
/models
```
---
### Scaleway
[Scaleway Generative APIs](https://www.scaleway.com/en/docs/generative-apis/) を Opencode で使用するには:
1. [Scaleway Console IAM settings](https://console.scaleway.com/iam/api-keys) に移動して、新しい API キーを生成します。
2. `/connect` コマンドを実行し、**Scaleway** を検索します。
```txt
/connect
```
3. Scaleway API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、_devstral-2-123b-instruct-2512_ や _gpt-oss-120b_ などのモデルを選択します。
```txt
/models
```
---
### Together AI
1. [Together AI console](https://api.together.ai) に移動し、アカウントを作成し、[**キーの追加**] をクリックします。
2. `/connect` コマンドを実行し、**Together AI** を検索します。
```txt
/connect
```
3. Together AI API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、_Kimi K2 Instruct_ のようなモデルを選択します。
```txt
/models
```
---
### Venice AI
1. [Venice AI console](https://venice.ai) に移動し、アカウントを作成し、API キーを生成します。
2. `/connect` コマンドを実行し、**Venice AI** を検索します。
```txt
/connect
```
3. Venice AI API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、_Llama 3.3 70B_ のようなモデルを選択します。
```txt
/models
```
---
### Vercel AI Gateway
Vercel AI Gateway を使用すると、統合エンドポイントを通じて OpenAI、Anthropic、Google、xAI などのモデルにアクセスできます。モデルは値上げなしの定価で提供されます。
1. [Vercel ダッシュボード ](https://vercel.com/) に移動し、**AI ゲートウェイ** タブに移動し、**API キー** をクリックして新しい API キーを作成します。
2. `/connect` コマンドを実行し、**Vercel AI Gateway** を検索します。
```txt
/connect
```
3. Vercel AI Gateway API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行してモデルを選択します。
```txt
/models
```
OpenCode 設定を通じてモデルをカスタマイズすることもできます。プロバイダーのルーティング順序を指定する例を次に示します。
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"vercel": {
"models": {
"anthropic/claude-sonnet-4": {
"options": {
"order": ["anthropic", "vertex"]
}
}
}
}
}
}
```
いくつかの便利なルーティングオプション:
| オプション | 説明 |
| ------------------- | ---------------------------------------------------- |
| `order` | 試行するプロバイダーシーケンス |
| `only` | 特定のプロバイダーに制限する |
| `zeroDataRetention` | データ保持ポリシーがゼロのプロバイダーのみを使用する |
---
### xAI
1. [xAI console](https://console.x.ai/) に移動し、アカウントを作成し、API キーを生成します。
2. `/connect` コマンドを実行し、**xAI** を検索します。
```txt
/connect
```
3. xAI API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、_Grok Beta_ のようなモデルを選択します。
```txt
/models
```
---
### Z.AI
1. [Z.AI API コンソール ](https://z.ai/manage-apikey/apikey-list) に移動し、アカウントを作成し、**新しい API キーの作成** をクリックします。
2. `/connect` コマンドを実行し、**Z.AI** を検索します。
```txt
/connect
```
**GLM コーディングプラン**に加入している場合は、**Z.AI コーディングプラン**を選択します。
3. Z.AI API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. `/models` コマンドを実行して、_GLM-4.7_ のようなモデルを選択します。
```txt
/models
```
---
### ZenMux
1. [ZenMux ダッシュボード](https://zenmux.ai/settings/keys) に移動し、[**API キーの作成**] をクリックして、キーをコピーします。
2. `/connect` コマンドを実行し、ZenMux を検索します。
```txt
/connect
```
3. プロバイダーの API キーを入力します。
```txt
┌ API key
│
│
└ enter
```
4. 多くの ZenMux モデルはデフォルトでプリロードされており、`/models` コマンドを実行して必要なモデルを選択します。
```txt
/models
```
OpenCode 設定を通じて追加のモデルを追加することもできます。
```json title="opencode.json" {6}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"zenmux": {
"models": {
"somecoolnewmodel": {}
}
}
}
}
```
---
## カスタムプロバイダー
`/connect` コマンドにリストされていない **OpenAI 互換**プロバイダーを追加するには:
:::tip
OpenAI と互換性のある任意のプロバイダーを OpenCode で使用できます。最新の AI プロバイダーのほとんどは、OpenAI 互換の API を提供しています。
:::
1. `/connect` コマンドを実行し、**その他**まで下にスクロールします。
```bash
$ /connect
┌ Add credential
│
◆ Select provider
│ ...
│ ● Other
└
```
2. プロバイダーの一意の ID を入力します。
```bash
$ /connect
┌ Add credential
│
◇ Enter provider id
│ myprovider
└
```
:::note
覚えやすい ID を選択してください。これを設定ファイルで使用します。
:::
3. プロバイダーの API キーを入力します。
```bash
$ /connect
┌ Add credential
│
▲ This only stores a credential for myprovider - you will need to configure it in opencode.json, check the docs for examples.
│
◇ Enter your API key
│ sk-...
└
```
4. プロジェクトディレクトリで `opencode.json` ファイルを作成または更新します。
```json title="opencode.json" ""myprovider"" {5-15}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"myprovider": {
"npm": "@ai-sdk/openai-compatible",
"name": "My AI ProviderDisplay Name",
"options": {
"baseURL": "https://api.myprovider.com/v1"
},
"models": {
"my-model-name": {
"name": "My Model Display Name"
}
}
}
}
}
```
構成オプションは次のとおりです。
- **npm**: 使用する AI SDK パッケージ、OpenAI 互換プロバイダーの場合は `@ai-sdk/openai-compatible`
- **name**: UI での表示名。
- **models**: 利用可能なモデル。
- **options.baseURL**: API エンドポイント URL。
- **options.apiKey**: 認証を使用しない場合は、オプションで API キーを設定します。
- **options.headers**: 必要に応じてカスタムヘッダーを設定します。
詳細オプションの詳細については、以下の例を参照してください。
5. `/models` コマンドを実行すると、カスタムプロバイダーとモデルが選択リストに表示されます。
---
##### 例
次に、`apiKey`、`headers`、およびモデル `limit` オプションを設定する例を示します。
```json title="opencode.json" {9,11,17-20}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"myprovider": {
"npm": "@ai-sdk/openai-compatible",
"name": "My AI ProviderDisplay Name",
"options": {
"baseURL": "https://api.myprovider.com/v1",
"apiKey": "{env:ANTHROPIC_API_KEY}",
"headers": {
"Authorization": "Bearer custom-token"
}
},
"models": {
"my-model-name": {
"name": "My Model Display Name",
"limit": {
"context": 200000,
"output": 65536
}
}
}
}
}
}
```
設定の詳細:
- **apiKey**: `env` 変数構文を使用して設定します。[詳細については ](/docs/config#env-vars).
- **headers**: 各リクエストとともに送信されるカスタムヘッダー。
- **limit.context**: モデルが受け入れる最大入力トークン。
- **limit.output**: モデルが生成できる最大出力トークン。
`limit` フィールドを使用すると、OpenCode はコンテキストがどのくらい残っているかを理解できます。標準プロバイダーは、これらを models.dev から自動的に取得します。
---
## トラブルシューティング
プロバイダーの設定で問題が発生した場合は、次の点を確認してください。
1. **認証設定を確認します**: `opencode auth list` を実行して、資格情報が正しいかどうかを確認します。
プロバイダー用のものが設定に追加されます。
これは、認証に環境変数に依存する Amazon Bedrock のようなプロバイダーには当てはまりません。
2. カスタムプロバイダーの場合は、OpenCode 設定を確認し、次のことを行います。
- `/connect` コマンドで使用されるプロバイダー ID が、OpenCode 設定内の ID と一致することを確認してください。
- プロバイダーには適切な npm パッケージが使用されます。たとえば、Cerebras には `@ai-sdk/cerebras` を使用します。他のすべての OpenAI 互換プロバイダーの場合は、`@ai-sdk/openai-compatible` を使用します。
- `options.baseURL` フィールドで正しい API エンドポイントが使用されていることを確認してください。
|