File size: 66,892 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 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 | ---
title: Providers
description: Using any LLM provider in OpenCode.
---
import config from "../../../config.mjs"
export const console = config.console
OpenCode uses the [AI SDK](https://ai-sdk.dev/) and [Models.dev](https://models.dev) to support **75+ LLM providers** and it supports running local models.
To add a provider you need to:
1. Add the API keys for the provider using the `/connect` command.
2. Configure the provider in your OpenCode config.
---
### Credentials
When you add a provider's API keys with the `/connect` command, they are stored
in `~/.local/share/opencode/auth.json`.
---
### Config
You can customize the providers through the `provider` section in your OpenCode
config.
---
#### Base URL
You can customize the base URL for any provider by setting the `baseURL` option. This is useful when using proxy services or custom endpoints.
```json title="opencode.json" {6}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"anthropic": {
"options": {
"baseURL": "https://api.anthropic.com/v1"
}
}
}
}
```
---
#### Hiding models
You can hide specific models from the `/models` picker for a provider using the `blacklist` option. This is useful when a provider exposes models you don't want to use or select.
```json title="opencode.json" {6}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"anthropic": {
"blacklist": ["claude-opus-4-20250514"]
}
}
}
```
The inverse `whitelist` option hides every model except the ones listed.
```json title="opencode.json" {6}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"anthropic": {
"whitelist": ["claude-sonnet-4-20250514"]
}
}
}
```
Both options take an array of model IDs β the same IDs shown in the `/models` picker.
- `blacklist` removes the listed models from the picker.
- `whitelist` keeps only the listed models and hides the rest.
- You can combine them: `whitelist` narrows the set, then `blacklist` removes entries from it.
---
## OpenCode Zen
OpenCode Zen is a list of models provided by the OpenCode team that have been
tested and verified to work well with OpenCode. [Learn more](/docs/zen).
:::tip
If you are new, we recommend starting with OpenCode Zen.
:::
1. Run the `/connect` command in the TUI, select `OpenCode Zen`, and head to [opencode.ai/auth](https://opencode.ai/zen).
```txt
/connect
```
2. Sign in, add your billing details, and copy your API key.
3. Paste your API key.
```txt
β API key
β
β
β enter
```
4. Run `/models` in the TUI to see the list of models we recommend.
```txt
/models
```
It works like any other provider in OpenCode and is completely optional to use.
---
## OpenCode Go
OpenCode Go is a low cost subscription plan that provides reliable access to popular open coding models provided by the OpenCode team that have been
tested and verified to work well with OpenCode.
1. Run the `/connect` command in the TUI, select `OpenCode Go`, and head to [opencode.ai/auth](https://opencode.ai/zen).
```txt
/connect
```
2. Sign in, add your billing details, and copy your API key.
3. Paste your API key.
```txt
β API key
β
β
β enter
```
4. Run `/models` in the TUI to see the list of models we recommend.
```txt
/models
```
It works like any other provider in OpenCode and is completely optional to use.
---
## Directory
Let's look at some of the providers in detail. If you'd like to add a provider to the
list, feel free to open a PR.
:::note
Don't see a provider here? Submit a PR.
:::
---
### 302.AI
1. Head over to the [302.AI console](https://302.ai/), create an account, and generate an API key.
2. Run the `/connect` command and search for **302.AI**.
```txt
/connect
```
3. Enter your 302.AI API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model.
```txt
/models
```
---
### Amazon Bedrock
To use Amazon Bedrock with OpenCode:
1. Head over to the **Model catalog** in the Amazon Bedrock console and request
access to the models you want.
:::tip
You need to have access to the model you want in Amazon Bedrock.
:::
2. **Configure authentication** using one of the following methods:
***
#### Environment Variables (Quick Start)
Set one of these environment variables while running opencode:
```bash
# Option 1: Using AWS access keys
AWS_ACCESS_KEY_ID=XXX AWS_SECRET_ACCESS_KEY=YYY opencode
# Option 2: Using named AWS profile
AWS_PROFILE=my-profile opencode
# Option 3: Using Bedrock bearer token
AWS_BEARER_TOKEN_BEDROCK=XXX opencode
```
Or add them to your bash profile:
```bash title="~/.bash_profile"
export AWS_PROFILE=my-dev-profile
export AWS_REGION=us-east-1
```
***
#### Configuration File (Recommended)
For project-specific or persistent configuration, use `opencode.json`:
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"amazon-bedrock": {
"options": {
"region": "us-east-1",
"profile": "my-aws-profile"
}
}
}
}
```
**Available options:**
- `region` - AWS region (e.g., `us-east-1`, `eu-west-1`)
- `profile` - AWS named profile from `~/.aws/credentials`
- `endpoint` - Custom endpoint URL for VPC endpoints (alias for generic `baseURL` option)
:::tip
Configuration file options take precedence over environment variables.
:::
***
#### Advanced: VPC Endpoints
If you're using VPC endpoints for Bedrock:
```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
The `endpoint` option is an alias for the generic `baseURL` option, using AWS-specific terminology. If both `endpoint` and `baseURL` are specified, `endpoint` takes precedence.
:::
***
#### Authentication Methods
- **`AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY`**: Create an IAM user and generate access keys in the AWS Console
- **`AWS_PROFILE`**: Use named profiles from `~/.aws/credentials`. First configure with `aws configure --profile my-profile` or `aws sso login`
- **`AWS_BEARER_TOKEN_BEDROCK`**: Generate long-term API keys from the Amazon Bedrock console
- **`AWS_WEB_IDENTITY_TOKEN_FILE` / `AWS_ROLE_ARN`**: For EKS IRSA (IAM Roles for Service Accounts) or other Kubernetes environments with OIDC federation. These environment variables are automatically injected by Kubernetes when using service account annotations.
***
#### Authentication Precedence
Amazon Bedrock uses the following authentication priority:
1. **Bearer Token** - `AWS_BEARER_TOKEN_BEDROCK` environment variable or token from `/connect` command
2. **AWS Credential Chain** - Profile, access keys, shared credentials, IAM roles, Web Identity Tokens (EKS IRSA), instance metadata
:::note
When a bearer token is set (via `/connect` or `AWS_BEARER_TOKEN_BEDROCK`), it takes precedence over all AWS credential methods including configured profiles.
:::
3. Run the `/models` command to select the model you want.
```txt
/models
```
:::note
For custom inference profiles, use the model and provider name in the key and set the `id` property to the arn. This ensures correct caching.
:::
```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. Once you've signed up, run the `/connect` command and select Anthropic.
```txt
/connect
```
2. Here you can select the **Claude Pro/Max** option and it'll open your browser
and ask you to authenticate.
```txt
β Select auth method
β
β Manually enter API Key
β
```
3. Now all the Anthropic models should be available when you use the `/models` command.
```txt
/models
```
:::info
There are plugins that allow you to use your Claude Pro/Max models with
OpenCode. Anthropic explicitly prohibits this.
Previous versions of OpenCode came bundled with these plugins but that is no
longer the case as of 1.3.0
Other companies support freedom of choice with developer tooling - you can use
the following subscriptions in OpenCode with zero setup:
- ChatGPT Plus
- Github Copilot
- Gitlab Duo
:::
---
### Atomic Chat
You can configure opencode to use local models through [Atomic Chat](https://atomic.chat), a desktop application that runs local LLMs behind an OpenAI-compatible API server (default endpoint `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>"
}
}
}
}
}
```
In this example:
- `atomic-chat` is the custom provider ID. This can be any string you want.
- `npm` specifies the package to use for this provider. Here, `@ai-sdk/openai-compatible` is used for any OpenAI-compatible API.
- `name` is the display name for the provider in the UI.
- `options.baseURL` is the endpoint for the local server. Change the host and port to match your Atomic Chat setup.
- `models` is a map of model IDs to their display names. Each ID must match the `id` returned by `GET /v1/models` β run `curl http://127.0.0.1:1337/v1/models` to list the ids currently loaded in Atomic Chat.
:::tip
If tool calls aren't working well, pick a loaded model with strong tool-calling support (for example, a Qwen-Coder or DeepSeek-Coder variant).
:::
---
### Azure OpenAI
:::note
If you encounter "I'm sorry, but I cannot assist with that request" errors, try changing the content filter from **DefaultV2** to **Default** in your Azure resource.
:::
1. Head over to the [Azure portal](https://portal.azure.com/) and create an **Azure OpenAI** resource. You'll need:
- **Resource name**: This becomes part of your API endpoint (`https://RESOURCE_NAME.openai.azure.com/`)
- **API key**: Either `KEY 1` or `KEY 2` from your resource
2. Go to [Azure AI Foundry](https://ai.azure.com/) and deploy a model.
:::note
The deployment name must match the model name for opencode to work properly.
:::
3. Run the `/connect` command and search for **Azure**.
```txt
/connect
```
4. Enter your API key.
```txt
β API key
β
β
β enter
```
5. Set your resource name as an environment variable:
```bash
AZURE_RESOURCE_NAME=XXX opencode
```
Or add it to your bash profile:
```bash title="~/.bash_profile"
export AZURE_RESOURCE_NAME=XXX
```
6. Run the `/models` command to select your deployed model.
```txt
/models
```
#### Microsoft Entra ID (Azure CLI)
You can use your Azure CLI session instead of an API key. [Install the Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli), run `az login`, then run `/connect`, select **Azure**, and choose **Microsoft Entra ID (Azure CLI)**. Enter the Azure Resource name when prompted. Use `az login --tenant TENANT_ID` if the Resource belongs to a different tenant.
Find the Resource name by opening your Azure OpenAI or Foundry Resource in the [Azure portal](https://portal.azure.com/) or [Microsoft Foundry](https://ai.azure.com/). It is also the first part of the endpoint: `my-models` in `https://my-models.openai.azure.com/` or `https://my-models.services.ai.azure.com/`. If your identity can list Resources, you can also find their names and Resource groups with:
```bash
az cognitiveservices account list \
--query "[].{name:name,resourceGroup:resourceGroup}" \
--output table
```
OpenCode does not query Azure management APIs or discover deployments. Select a model whose catalog name matches your deployment, or configure its deployment name explicitly:
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"azure": {
"models": {
"gpt-5-mini": {
"id": "gpt-production"
}
}
}
}
}
```
Assign your identity the inference role required by the deployment: **Cognitive Services OpenAI User** for Azure OpenAI models or **Cognitive Services User** for other Foundry models. OpenCode refreshes access tokens through the Azure CLI, including versions earlier than 2.54.0, so you only need to sign in again when the CLI session expires.
---
### Azure Cognitive Services
1. Head over to the [Azure portal](https://portal.azure.com/) and create an **Azure OpenAI** resource. You'll need:
- **Resource name**: This becomes part of your API endpoint (`https://AZURE_COGNITIVE_SERVICES_RESOURCE_NAME.cognitiveservices.azure.com/`)
- **API key**: Either `KEY 1` or `KEY 2` from your resource
2. Go to [Azure AI Foundry](https://ai.azure.com/) and deploy a model.
:::note
The deployment name must match the model name for opencode to work properly.
:::
3. Run the `/connect` command and search for **Azure Cognitive Services**.
```txt
/connect
```
4. Enter your API key.
```txt
β API key
β
β
β enter
```
5. Set your resource name as an environment variable:
```bash
AZURE_COGNITIVE_SERVICES_RESOURCE_NAME=XXX opencode
```
Or add it to your bash profile:
```bash title="~/.bash_profile"
export AZURE_COGNITIVE_SERVICES_RESOURCE_NAME=XXX
```
6. Run the `/models` command to select your deployed model.
```txt
/models
```
---
### Baseten
1. Head over to the [Baseten](https://app.baseten.co/), create an account, and generate an API key.
2. Run the `/connect` command and search for **Baseten**.
```txt
/connect
```
3. Enter your Baseten API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model.
```txt
/models
```
---
### Cerebras
1. Head over to the [Cerebras console](https://inference.cerebras.ai/), create an account, and generate an API key.
2. Run the `/connect` command and search for **Cerebras**.
```txt
/connect
```
3. Enter your Cerebras API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model like _Qwen 3 Coder 480B_.
```txt
/models
```
---
### Cloudflare AI Gateway
Cloudflare AI Gateway lets you access models from OpenAI, Anthropic, Workers AI, and more through a unified endpoint. With [Unified Billing](https://developers.cloudflare.com/ai-gateway/features/unified-billing/) you don't need separate API keys for each provider.
1. Head over to the [Cloudflare dashboard](https://dash.cloudflare.com/), navigate to **AI** > **AI Gateway**, and create a new gateway. Note your **Account ID** and **Gateway ID**.
2. Run the `/connect` command and search for **Cloudflare AI Gateway**.
```txt
/connect
```
3. Enter your **Account ID** when prompted.
```txt
β Enter your Cloudflare Account ID
β
β
β enter
```
4. Enter your **Gateway ID** when prompted.
```txt
β Enter your Cloudflare AI Gateway ID
β
β
β enter
```
5. Enter your **Cloudflare API token**.
```txt
β Gateway API token
β
β
β enter
```
6. Run the `/models` command to select a model.
```txt
/models
```
You can also add models through your opencode config.
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"cloudflare-ai-gateway": {
"models": {
"openai/gpt-4o": {},
"anthropic/claude-sonnet-4": {}
}
}
}
}
```
Alternatively, you can set environment variables instead of using `/connect`.
```bash title="~/.bash_profile"
export CLOUDFLARE_ACCOUNT_ID=your-32-character-account-id
export CLOUDFLARE_GATEWAY_ID=your-gateway-id
export CLOUDFLARE_API_TOKEN=your-api-token
```
---
### Cloudflare Workers AI
Cloudflare Workers AI lets you run AI models on Cloudflare's global network directly via REST API, with no separate provider accounts needed for supported models.
1. Head over to the [Cloudflare dashboard](https://dash.cloudflare.com/), navigate to **Workers AI**, and select **Use REST API** to get your **Account ID** and create an API token.
2. Run the `/connect` command and search for **Cloudflare Workers AI**.
```txt
/connect
```
3. Enter your **Account ID** when prompted.
```txt
β Enter your Cloudflare Account ID
β
β
β enter
```
4. Enter your **Cloudflare API key**.
```txt
β API key
β
β
β enter
```
5. Run the `/models` command to select a model.
```txt
/models
```
Alternatively, you can set environment variables instead of using `/connect`.
```bash title="~/.bash_profile"
export CLOUDFLARE_ACCOUNT_ID=your-32-character-account-id
export CLOUDFLARE_API_KEY=your-api-token
```
---
### Cortecs
1. Head over to the [Cortecs console](https://cortecs.ai/), create an account, and generate an API key.
2. Run the `/connect` command and search for **Cortecs**.
```txt
/connect
```
3. Enter your Cortecs API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model like _Kimi K2 Instruct_.
```txt
/models
```
---
### DeepSeek
1. Head over to the [DeepSeek console](https://platform.deepseek.com/), create an account, and click **Create new API key**.
2. Run the `/connect` command and search for **DeepSeek**.
```txt
/connect
```
3. Enter your DeepSeek API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a DeepSeek model like _DeepSeek V4 Pro_.
```txt
/models
```
---
### Deep Infra
1. Head over to the [Deep Infra dashboard](https://deepinfra.com/dash), create an account, and generate an API key.
2. Run the `/connect` command and search for **Deep Infra**.
```txt
/connect
```
3. Enter your Deep Infra API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model.
```txt
/models
```
---
### DigitalOcean
DigitalOcean's [Inference Engine](https://docs.digitalocean.com/products/inference/) provides access to open models like GPT-OSS, Llama, Qwen, and DeepSeek, plus custom [Inference Routers](https://docs.digitalocean.com/products/inference/how-to/use-inference-router/) that route each request to the cheapest, fastest, or best-fit model for a task.
OpenCode supports two authentication methods:
- **OAuth (Recommended)** β Sign in to your DigitalOcean account; OpenCode uses your DigitalOcean API token directly for inference and discovers your Inference Routers.
- **Model Access Key** β Paste an existing key from the DigitalOcean console.
#### OAuth (Recommended)
1. Run the `/connect` command and search for **DigitalOcean**.
```txt
/connect
```
2. Select **Login with DigitalOcean**.
```txt
β Select auth method
β
β Login with DigitalOcean
β Paste Model Access Key
β
```
3. Your browser opens to authorize OpenCode. Sign in and approve.
:::note
OpenCode requests `genai:read` and `inference:query` OAuth scopes. Your DigitalOcean API token is used directly for inference β no separate Model Access Key is created.
:::
:::note
Inference Routers only appear in the model picker after OAuth. Pasting a Model Access Key manually does not discover routers.
:::
4. Run the `/models` command. Your Inference Routers appear as the format `router:` in the model selection.
```txt
/models
```
5. To pick up newly created Inference Routers, re-run `/connect` and select **DigitalOcean** again.
#### Using a Model Access Key
If you'd rather paste a key directly:
1. Head over to the **Manage** page in the Inference section of the [DigitalOcean console](https://cloud.digitalocean.com/) and create a new key.
2. Run the `/connect` command and select **DigitalOcean**, then **Paste Model Access Key**.
```txt
β Enter your DigitalOcean Model Access Key
β
β
β enter
```
:::note
Inference Routers are not auto-discovered with this method. To surface them in the model picker, sign in via OAuth instead.
:::
3. Run the `/models` command to select a model.
```txt
/models
```
#### Environment Variable
Alternatively, set your Model Access Key as an environment variable.
```bash frame="none"
export DIGITALOCEAN_ACCESS_TOKEN=your-model-access-key
```
#### Inference Routers
Inference Routers let you define a routing policy across multiple models β picking the cheapest, fastest, or most appropriate model per request based on the task. After OAuth, OpenCode surfaces each router as `router:<router-name>` in the model picker.
Selecting a router model is a drop-in replacement for any other model β OpenCode forwards your request and DigitalOcean picks the underlying model based on your router's policy. Learn more about [Inference Routers](https://docs.digitalocean.com/products/inference/how-to/use-inference-router/)
---
### Eden AI
[Eden AI](https://www.edenai.co/) is an EU-based gateway that serves models from many vendors over a single OpenAI-compatible API, with a separate EU endpoint for teams that need inference to stay in the EU.
1. Head over to the [Eden AI platform](https://app.edenai.run/user/register) to create an account and generate an API key.
2. Run the `/connect` command and search for **Eden AI**.
```txt
/connect
```
3. Enter your Eden AI API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model like _Mistral Large 3_ or _Claude Sonnet 5_.
```txt
/models
```
Eden AI model ids are themselves in `vendor/model` form, so a full reference has three segments, for example `edenai/anthropic/claude-sonnet-5`.
5. To keep requests on Eden AI's EU gateway, set its base URL.
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"edenai": {
"options": {
"baseURL": "https://api.eu.edenai.run/v3"
}
}
}
}
```
The default is `https://api.edenai.run/v3`, so this swaps the global endpoint for the EU one. The EU endpoint serves the subset of the catalog that is available in the EU, so a model chosen in step 4 may not be reachable through it.
---
### FrogBot
1. Head over to the [FrogBot dashboard](https://app.frogbot.ai/signup), create an account, and generate an API key.
2. Run the `/connect` command and search for **FrogBot**.
```txt
/connect
```
3. Enter your FrogBot API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model.
```txt
/models
```
---
### Fireworks AI
1. Head over to the [Fireworks AI console](https://app.fireworks.ai/), create an account, and click **Create API Key**.
2. Run the `/connect` command and search for **Fireworks AI**.
```txt
/connect
```
3. Enter your Fireworks AI API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model like _Kimi K2 Instruct_.
```txt
/models
```
---
### GitLab Duo
:::caution[Experimental]
GitLab Duo support in OpenCode is experimental. Features, configuration, and
behavior may change in future releases.
:::
OpenCode integrates with the [GitLab Duo Agent Platform](https://docs.gitlab.com/user/duo_agent_platform/),
providing AI-powered agentic chat with native tool calling capabilities.
:::note[License requirements]
GitLab Duo Agent Platform requires a **Premium** or **Ultimate** GitLab
subscription. It is available on GitLab.com and GitLab Self-Managed.
See [GitLab Duo Agent Platform prerequisites](https://docs.gitlab.com/user/duo_agent_platform/#prerequisites)
for full requirements.
:::
1. Run the `/connect` command and select GitLab.
```txt
/connect
```
2. Choose your authentication method:
```txt
β Select auth method
β
β OAuth (Recommended)
β Personal Access Token
β
```
#### Using OAuth (Recommended)
Select **OAuth** and your browser will open for authorization.
#### Using Personal Access Token
1. Go to [GitLab User Settings > Access Tokens](https://gitlab.com/-/user_settings/personal_access_tokens)
2. Click **Add new token**
3. Name: `OpenCode`, Scopes: `api`
4. Copy the token (starts with `glpat-`)
5. Enter it in the terminal
3. Run the `/models` command to see available models.
```txt
/models
```
Three Claude-based models are available:
- **duo-chat-haiku-4-5** (Default) - Fast responses for quick tasks
- **duo-chat-sonnet-4-5** - Balanced performance for most workflows
- **duo-chat-opus-4-5** - Most capable for complex analysis
:::note
You can also specify 'GITLAB_TOKEN' environment variable if you don't want
to store token in opencode auth storage.
:::
##### Self-Hosted GitLab
:::note[compliance note]
OpenCode uses a small model for some AI tasks like generating the session title.
It is configured to use gpt-5-nano by default, hosted by Zen. To lock OpenCode
to only use your own GitLab-hosted instance, add the following to your
`opencode.json` file. It is also recommended to disable session sharing.
```json
{
"$schema": "https://opencode.ai/config.json",
"small_model": "gitlab/duo-chat-haiku-4-5",
"share": "disabled"
}
```
:::
For self-hosted GitLab instances:
```bash
export GITLAB_INSTANCE_URL=https://gitlab.company.com
export GITLAB_TOKEN=glpat-...
```
If your instance runs a custom AI Gateway:
```bash
GITLAB_AI_GATEWAY_URL=https://ai-gateway.company.com
```
Or add to your bash profile:
```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
Your GitLab administrator must:
1. [Turn on GitLab Duo](https://docs.gitlab.com/user/duo_agent_platform/turn_on_off/#turn-gitlab-duo-on-or-off)
for the user, group, or instance
2. [Turn on the Agent Platform](https://docs.gitlab.com/user/duo_agent_platform/turn_on_off/#turn-gitlab-duo-agent-platform-on-or-off)
(GitLab 18.8+) or [enable beta and experimental features](https://docs.gitlab.com/user/duo_agent_platform/turn_on_off/#turn-on-beta-and-experimental-features)
(GitLab 18.7 and earlier)
3. For Self-Managed, [configure your instance](https://docs.gitlab.com/administration/gitlab_duo/configure/gitlab_self_managed/)
:::
##### OAuth for Self-Hosted instances
In order to make Oauth working for your self-hosted instance, you need to create
a new application (Settings β Applications) with the
callback URL `http://127.0.0.1:8080/callback` and following scopes:
- api (Access the API on your behalf)
- read_user (Read your personal information)
- read_repository (Allows read-only access to the repository)
Then expose application ID as environment variable:
```bash
export GITLAB_OAUTH_CLIENT_ID=your_application_id_here
```
More documentation on [opencode-gitlab-auth](https://www.npmjs.com/package/opencode-gitlab-auth) homepage.
##### Configuration
Customize through `opencode.json`:
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"gitlab": {
"options": {
"instanceUrl": "https://gitlab.com"
}
}
}
}
```
##### GitLab Duo Agent Platform (DAP) Workflow Models
DAP workflow models provide an alternative execution path that routes tool calls
through GitLab's Duo Workflow Service (DWS) instead of the standard agentic chat.
When a `duo-workflow-*` model is selected, OpenCode will:
1. Discover available models from your GitLab namespace
2. Present a selection picker if multiple models are available
3. Cache the selected model to disk for fast subsequent startups
4. Route tool execution requests through OpenCode's permission-gated tool system
Available DAP workflow models follow the `duo-workflow-*` naming convention and
are dynamically discovered from your GitLab instance.
##### GitLab API Tools (Optional, but highly recommended)
To access GitLab tools (merge requests, issues, pipelines, CI/CD, etc.):
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-gitlab-plugin"]
}
```
This plugin provides comprehensive GitLab repository management capabilities including MR reviews, issue tracking, pipeline monitoring, and more.
---
### GitHub Copilot
To use your GitHub Copilot subscription with opencode:
:::note
Some models might need a [Pro+
subscription](https://github.com/features/copilot/plans) to use.
:::
1. Run the `/connect` command and search for GitHub Copilot.
```txt
/connect
```
2. Navigate to [github.com/login/device](https://github.com/login/device) and enter the code.
```txt
β Login with GitHub Copilot
β
β https://github.com/login/device
β
β Enter code: 8F43-6FCF
β
β Waiting for authorization...
```
3. Now run the `/models` command to select the model you want.
```txt
/models
```
---
### GMI Cloud
To use GMI Cloud with OpenCode:
1. Head over to the [GMI Cloud console](https://console.gmicloud.ai/) to create an API key. You can also review the [API reference](https://docs.gmicloud.ai/inference-engine/api-reference/llm-api-reference) for the endpoint details.
2. Run the `/connect` command and search for **GMI Cloud**.
```txt
/connect
```
3. Enter your GMI Cloud API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select the model you want.
```txt
/models
```
---
### Google Vertex AI
To use Google Vertex AI with OpenCode:
1. Head over to the **Model Garden** in the Google Cloud Console and check the
models available in your region.
:::note
You need to have a Google Cloud project with Vertex AI API enabled.
:::
2. Set the required environment variables:
- `GOOGLE_CLOUD_PROJECT`: Your Google Cloud project ID
- `VERTEX_LOCATION` (optional): The region for Vertex AI (defaults to `global`)
- Authentication (choose one):
- `GOOGLE_APPLICATION_CREDENTIALS`: Path to your service account JSON key file
- Authenticate using gcloud CLI: `gcloud auth application-default login`
Set them while running opencode.
```bash
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json GOOGLE_CLOUD_PROJECT=your-project-id opencode
```
Or add them to your bash profile.
```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
The `global` region improves availability and reduces errors at no extra cost. Use regional endpoints (e.g., `us-central1`) for data residency requirements. [Learn more](https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/use-partner-models#regional_and_global_endpoints)
:::
3. Run the `/models` command to select the model you want.
```txt
/models
```
---
### Groq
1. Head over to the [Groq console](https://console.groq.com/), click **Create API Key**, and copy the key.
2. Run the `/connect` command and search for Groq.
```txt
/connect
```
3. Enter the API key for the provider.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select the one you want.
```txt
/models
```
---
### Hugging Face
[Hugging Face Inference Providers](https://huggingface.co/docs/inference-providers) provides access to open models supported by 17+ providers.
1. Head over to [Hugging Face settings](https://huggingface.co/settings/tokens/new?ownUserPermissions=inference.serverless.write&tokenType=fineGrained) to create a token with permission to make calls to Inference Providers.
2. Run the `/connect` command and search for **Hugging Face**.
```txt
/connect
```
3. Enter your Hugging Face token.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model like _Kimi-K2-Instruct_ or _GLM-4.6_.
```txt
/models
```
---
### Helicone
[Helicone](https://helicone.ai) is an LLM observability platform that provides logging, monitoring, and analytics for your AI applications. The Helicone AI Gateway routes your requests to the appropriate provider automatically based on the model.
1. Head over to [Helicone](https://helicone.ai), create an account, and generate an API key from your dashboard.
2. Run the `/connect` command and search for **Helicone**.
```txt
/connect
```
3. Enter your Helicone API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model.
```txt
/models
```
For more providers and advanced features like caching and rate limiting, check the [Helicone documentation](https://docs.helicone.ai).
#### Optional Configs
In the event you see a feature or model from Helicone that isn't configured automatically through opencode, you can always configure it yourself.
Here's [Helicone's Model Directory](https://helicone.ai/models), you'll need this to grab the IDs of the models you want to add.
```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-20250514": {
"name": "Claude Sonnet 4",
},
},
},
},
}
```
#### Custom Headers
Helicone supports custom headers for features like caching, user tracking, and session management. Add them to your provider config using `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",
},
},
},
},
}
```
##### Session tracking
Helicone's [Sessions](https://docs.helicone.ai/features/sessions) feature lets you group related LLM requests together. Use the [opencode-helicone-session](https://github.com/H2Shami/opencode-helicone-session) plugin to automatically log each OpenCode conversation as a session in Helicone.
```bash
npm install -g opencode-helicone-session
```
Add it to your config.
```json title="opencode.json"
{
"plugin": ["opencode-helicone-session"]
}
```
The plugin injects `Helicone-Session-Id` and `Helicone-Session-Name` headers into your requests. In Helicone's Sessions page, you'll see each OpenCode conversation listed as a separate session.
##### Common Helicone headers
| Header | Description |
| -------------------------- | ------------------------------------------------------------- |
| `Helicone-Cache-Enabled` | Enable response caching (`true`/`false`) |
| `Helicone-User-Id` | Track metrics by user |
| `Helicone-Property-[Name]` | Add custom properties (e.g., `Helicone-Property-Environment`) |
| `Helicone-Prompt-Id` | Associate requests with prompt versions |
See the [Helicone Header Directory](https://docs.helicone.ai/helicone-headers/header-directory) for all available headers.
---
### llama.cpp
You can configure opencode to use local models through [llama.cpp's](https://github.com/ggml-org/llama.cpp) llama-server utility
```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
}
}
}
}
}
}
```
In this example:
- `llama.cpp` is the custom provider ID. This can be any string you want.
- `npm` specifies the package to use for this provider. Here, `@ai-sdk/openai-compatible` is used for any OpenAI-compatible API.
- `name` is the display name for the provider in the UI.
- `options.baseURL` is the endpoint for the local server.
- `models` is a map of model IDs to their configurations. The model name will be displayed in the model selection list.
---
### IO.NET
IO.NET offers 17 models optimized for various use cases:
1. Head over to the [IO.NET console](https://ai.io.net/), create an account, and generate an API key.
2. Run the `/connect` command and search for **IO.NET**.
```txt
/connect
```
3. Enter your IO.NET API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model.
```txt
/models
```
---
### LM Studio
You can configure opencode to use local models through LM Studio.
```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)"
}
}
}
}
}
```
In this example:
- `lmstudio` is the custom provider ID. This can be any string you want.
- `npm` specifies the package to use for this provider. Here, `@ai-sdk/openai-compatible` is used for any OpenAI-compatible API.
- `name` is the display name for the provider in the UI.
- `options.baseURL` is the endpoint for the local server.
- `models` is a map of model IDs to their configurations. The model name will be displayed in the model selection list.
---
### Moonshot AI
To use Kimi K2 from Moonshot AI:
1. Head over to the [Moonshot AI console](https://platform.moonshot.ai/console), create an account, and click **Create API key**.
2. Run the `/connect` command and search for **Moonshot AI**.
```txt
/connect
```
3. Enter your Moonshot API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select _Kimi K2_.
```txt
/models
```
---
### MiniMax
1. Head over to the [MiniMax API Console](https://platform.minimax.io/login), create an account, and generate an API key.
2. Run the `/connect` command and search for **MiniMax**.
```txt
/connect
```
3. Enter your MiniMax API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model like _M2.1_.
```txt
/models
```
---
### Modal
1. Create a [shared Endpoint](https://modal.com/endpoints) for the model you want to use.
2. Create a [proxy token](https://modal.com/docs/guide/endpoints#proxy-tokens), then join its ID and secret with a period:
```txt
wk-<id>.ws-<secret>
```
3. Run the `/connect` command, search for **Modal**, and enter the combined proxy token.
```txt
/connect
```
4. Run the `/models` command to select one of the endpoints in your Modal workspace.
```txt
/models
```
---
### NVIDIA
NVIDIA provides access to Nemotron models and many other open models through [build.nvidia.com](https://build.nvidia.com) for free.
1. Head over to [build.nvidia.com](https://build.nvidia.com), create an account, and generate an API key.
2. Run the `/connect` command and search for **NVIDIA**.
```txt
/connect
```
3. Enter your NVIDIA API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model like nemotron-3-super-120b-a12b.
```txt
/models
```
#### On-Prem / NIM
You can also use NVIDIA models locally via [NVIDIA NIM](https://docs.nvidia.com/nim/) by setting a custom base URL.
```json title="opencode.json" {6}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"nvidia": {
"options": {
"baseURL": "http://localhost:8000/v1"
}
}
}
}
```
#### Environment Variable
Alternatively, set your API key as an environment variable.
```bash frame="none"
export NVIDIA_API_KEY=nvapi-your-key-here
```
---
### Nebius Token Factory
1. Head over to the [Nebius Token Factory console](https://tokenfactory.nebius.com/), create an account, and click **Add Key**.
2. Run the `/connect` command and search for **Nebius Token Factory**.
```txt
/connect
```
3. Enter your Nebius Token Factory API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model like _Kimi K2 Instruct_.
```txt
/models
```
---
### Ollama
You can configure opencode to use local models through Ollama.
:::tip
Ollama can automatically configure itself for OpenCode. See the [Ollama integration docs](https://docs.ollama.com/integrations/opencode) for details.
:::
```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"
}
}
}
}
}
```
In this example:
- `ollama` is the custom provider ID. This can be any string you want.
- `npm` specifies the package to use for this provider. Here, `@ai-sdk/openai-compatible` is used for any OpenAI-compatible API.
- `name` is the display name for the provider in the UI.
- `options.baseURL` is the endpoint for the local server.
- `models` is a map of model IDs to their configurations. The model name will be displayed in the model selection list.
:::tip
If tool calls aren't working, try increasing `num_ctx` in Ollama. Start around 16k - 32k.
:::
---
### Ollama Cloud
To use Ollama Cloud with OpenCode:
1. Head over to [https://ollama.com/](https://ollama.com/) and sign in or create an account.
2. Navigate to **Settings** > **Keys** and click **Add API Key** to generate a new API key.
3. Copy the API key for use in OpenCode.
4. Run the `/connect` command and search for **Ollama Cloud**.
```txt
/connect
```
5. Enter your Ollama Cloud API key.
```txt
β API key
β
β
β enter
```
6. **Important**: Before using cloud models in OpenCode, you must pull the model information locally:
```bash
ollama pull gpt-oss:20b-cloud
```
7. Run the `/models` command to select your Ollama Cloud model.
```txt
/models
```
---
### OpenAI
We recommend signing up for [ChatGPT Plus or Pro](https://chatgpt.com/pricing).
1. Once you've signed up, run the `/connect` command and select OpenAI.
```txt
/connect
```
2. Here you can select the **ChatGPT Plus/Pro** option and it'll open your browser
and ask you to authenticate.
```txt
β Select auth method
β
β ChatGPT Plus/Pro
β Manually enter API Key
β
```
3. Now all the OpenAI models should be available when you use the `/models` command.
```txt
/models
```
##### Compute residency
For ChatGPT OAuth, OpenCode automatically applies a regional inference residency requirement when one is advertised by your workspace credentials. It forwards the compute residency value from the credential instead of maintaining a fixed list of regions. Data residency at rest does not imply regional inference.
##### Using API keys
If you already have an API key, you can select **Manually enter API Key** and paste it in your terminal.
---
### OpenCode Zen
OpenCode Zen is a list of tested and verified models provided by the OpenCode team. [Learn more](/docs/zen).
1. Sign in to **<a href={console}>OpenCode Zen</a>** and click **Create API Key**.
2. Run the `/connect` command and search for **OpenCode Zen**.
```txt
/connect
```
3. Enter your OpenCode API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model like _Qwen 3 Coder 480B_.
```txt
/models
```
---
### OpenRouter
1. Head over to the [OpenRouter dashboard](https://openrouter.ai/settings/keys), click **Create API Key**, and copy the key.
2. Run the `/connect` command and search for OpenRouter.
```txt
/connect
```
3. Enter the API key for the provider.
```txt
β API key
β
β
β enter
```
4. Many OpenRouter models are preloaded by default, run the `/models` command to select the one you want.
```txt
/models
```
You can also add additional models through your opencode config.
```json title="opencode.json" {6}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openrouter": {
"models": {
"somecoolnewmodel": {}
}
}
}
}
```
5. You can also customize them through your opencode config. Here's an example of specifying a provider
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openrouter": {
"models": {
"moonshotai/kimi-k2": {
"options": {
"provider": {
"order": ["baseten"],
"allow_fallbacks": false
}
}
}
}
}
}
}
```
---
### LLM Gateway
1. Head over to the [LLM Gateway dashboard](https://llmgateway.io/dashboard), click **Create API Key**, and copy the key.
2. Run the `/connect` command and search for LLM Gateway.
```txt
/connect
```
3. Enter the API key for the provider.
```txt
β API key
β
β
β enter
```
4. Many LLM Gateway models are preloaded by default, run the `/models` command to select the one you want.
```txt
/models
```
You can also add additional models through your opencode config.
```json title="opencode.json" {6}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"llmgateway": {
"models": {
"somecoolnewmodel": {}
}
}
}
}
```
5. You can also customize them through your opencode config. Here's an example of specifying a provider
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"llmgateway": {
"models": {
"glm-4.7": {
"name": "GLM 4.7"
},
"gpt-5.2": {
"name": "GPT-5.2"
},
"gemini-2.5-pro": {
"name": "Gemini 2.5 Pro"
},
"claude-3-5-sonnet-20241022": {
"name": "Claude 3.5 Sonnet"
}
}
}
}
}
```
---
### Poolside
[Poolside](https://poolside.ai) provides access to its models through an OpenAI-compatible API.
1. Head over to [platform.poolside.ai](https://platform.poolside.ai), sign in, open the **API Keys** tab, and click **New key** to generate an API key.
2. Run the `/connect` command and search for **Poolside**.
```txt
/connect
```
3. Enter your Poolside API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model.
```txt
/models
```
#### Poolside deployment
If your organization runs a Poolside deployment, configure it as a custom OpenAI-compatible provider. Store the API key or token from your Poolside administrator in `~/.secrets/poolside-key`. Use a unique provider ID and add the model IDs available from your deployment.
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"poolside-deployment": {
"npm": "@ai-sdk/openai-compatible",
"name": "Poolside deployment",
"options": {
"baseURL": "https://poolside.example.com/openai/v1",
"apiKey": "{file:~/.secrets/poolside-key}"
},
"models": {
"<served-model-id>": {
"name": "Poolside deployment model",
"reasoning": true,
"interleaved": {
"field": "reasoning_content"
}
}
}
}
}
}
```
Replace `poolside.example.com` with your deployment's host and `<served-model-id>` with a model ID returned by its `/openai/v1/models` endpoint. Model availability and thinking behavior depend on the deployment's configuration.
:::tip
You can also install [Poolside Agent CLI](https://github.com/poolsideai/pool) to use Poolside agents directly from your terminal.
:::
---
### SAP AI Core
SAP AI Core provides access to 40+ models from OpenAI, Anthropic, Google, Amazon, Meta, Mistral, and AI21 through a unified platform.
1. Go to your [SAP BTP Cockpit](https://account.hana.ondemand.com/), navigate to your SAP AI Core service instance, and create a service key.
:::tip
The service key is a JSON object containing `clientid`, `clientsecret`, `url`, and `serviceurls.AI_API_URL`. You can find your AI Core instance under **Services** > **Instances and Subscriptions** in the BTP Cockpit.
:::
2. Run the `/connect` command and search for **SAP AI Core**.
```txt
/connect
```
3. Enter your service key JSON.
```txt
β Service key
β
β
β enter
```
Or set the `AICORE_SERVICE_KEY` environment variable:
```bash
AICORE_SERVICE_KEY='{"clientid":"...","clientsecret":"...","url":"...","serviceurls":{"AI_API_URL":"..."}}' opencode
```
Or add it to your bash profile:
```bash title="~/.bash_profile"
export AICORE_SERVICE_KEY='{"clientid":"...","clientsecret":"...","url":"...","serviceurls":{"AI_API_URL":"..."}}'
```
4. Optionally set deployment ID and resource group:
```bash
AICORE_DEPLOYMENT_ID=your-deployment-id AICORE_RESOURCE_GROUP=your-resource-group opencode
```
:::note
These settings are optional and should be configured according to your SAP AI Core setup.
:::
5. Run the `/models` command to select from 40+ available models.
```txt
/models
```
---
### STACKIT
STACKIT AI Model Serving provides fully managed sovereign hosting environment for AI models, focusing on LLMs like Llama, Mistral, and Qwen, with maximum data sovereignty on European infrastructure.
1. Head over to [STACKIT Portal](https://portal.stackit.cloud), navigate to **AI Model Serving**, and create an auth token for your project.
:::tip
You need a STACKIT customer account, user account, and project before creating auth tokens.
:::
2. Run the `/connect` command and search for **STACKIT**.
```txt
/connect
```
3. Enter your STACKIT AI Model Serving auth token.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select from available models like _Qwen3-VL 235B_ or _Llama 3.3 70B_.
```txt
/models
```
---
### OVHcloud AI Endpoints
1. Head over to the [OVHcloud panel](https://ovh.com/manager). Navigate to the `Public Cloud` section, `AI & Machine Learning` > `AI Endpoints` and in `API Keys` tab, click **Create a new API key**.
2. Run the `/connect` command and search for **OVHcloud AI Endpoints**.
```txt
/connect
```
3. Enter your OVHcloud AI Endpoints API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model like _gpt-oss-120b_.
```txt
/models
```
---
### Scaleway
To use [Scaleway Generative APIs](https://www.scaleway.com/en/docs/generative-apis/) with Opencode:
1. Head over to the [Scaleway Console IAM settings](https://console.scaleway.com/iam/api-keys) to generate a new API key.
2. Run the `/connect` command and search for **Scaleway**.
```txt
/connect
```
3. Enter your Scaleway API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model like _devstral-2-123b-instruct-2512_ or _gpt-oss-120b_.
```txt
/models
```
---
### SCX.ai
[SCX.ai](https://scx.ai) is an Australian sovereign AI platform serving open models over an OpenAI-compatible API, hosted on renewable-powered infrastructure in Australia.
1. Head over to the [SCX.ai platform](https://platform.scx.ai) to create an account and generate an API key.
2. Run the `/connect` command and search for **SCX.ai**.
```txt
/connect
```
3. Enter your SCX.ai API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model like _MiniMax-M2.7_ or _GLM-5.2_.
```txt
/models
```
---
### Snowflake Cortex
[Snowflake Cortex](https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-rest-api) gives you access to frontier models (Claude, OpenAI GPT-5, and more) via an OpenAI-compatible API. All inference runs within the Snowflake perimeter and is billed in Snowflake credits. For per-model rates, see the [Snowflake Service Consumption Table](https://www.snowflake.com/legal-files/CreditConsumptionTable.pdf).
Don't have a Snowflake account? [Sign up for a free trial](https://signup.snowflake.com/?utm_source=opencode&utm_medium=docs&utm_campaign=cortex-provider).
opencode's core workflow for coding, editing files, and running commands relies on tool calling. Only the Claude and OpenAI families within Snowflake Cortex support this. The provider is limited to those families to support the core workflow.
OpenCode supports two authentication methods:
- **Browser OAuth (Recommended)** β sign in with your IdP/SSO; no secrets to manage, tokens refresh automatically.
- **Manual bearer token** β paste a PAT or JWT from the Snowflake console.
#### Browser OAuth (Recommended)
1. Run the `/connect` command and search for **Snowflake Cortex**.
```txt
/connect
```
2. Select **Login with Snowflake (External Browser)**.
```txt
β Select auth method
β
β Login with Snowflake (External Browser)
β Paste PAT or bearer token manually
β
```
3. Enter your [account identifier](https://docs.snowflake.com/en/user-guide/admin-account-identifier) when prompted, for example `myorg-myaccount` or `xy12345.us-east-1`.
```txt
β Snowflake Account Identifier
β
β
β enter
```
4. Optionally enter a Snowflake role to scope the session (e.g. `SYSADMIN`). Leave blank to use your default role.
5. Complete sign-in in the browser that opens. OpenCode captures the OAuth callback automatically and stores the token β no copy/paste needed.
6. Run the `/models` command to select a model.
```txt
/models
```
:::note
Browser OAuth uses Snowflake's built-in `SNOWFLAKE$LOCAL_APPLICATION` security integration ([docs](https://docs.snowflake.com/en/user-guide/oauth-local-applications)), which is rolling out to all accounts. To check availability in your account:
```sql
SHOW SECURITY INTEGRATIONS LIKE 'SNOWFLAKE$LOCAL_APPLICATION';
```
If the result is empty, use the **Manual bearer token** method below while the integration rolls out to your account.
:::
#### Manual bearer token
If you prefer to paste a token directly, or if `SNOWFLAKE$LOCAL_APPLICATION` is not yet available in your account:
1. Generate a [Programmatic Access Token (PAT)](https://docs.snowflake.com/en/user-guide/programmatic-access-tokens) in your Snowflake account.
2. Run the `/connect` command, search for **Snowflake Cortex**, and select **Paste PAT or bearer token manually**.
3. Enter your [account identifier](https://docs.snowflake.com/en/user-guide/admin-account-identifier) when prompted.
4. Paste your PAT.
5. Run the `/models` command to select a model.
```txt
/models
```
#### Environment variable
For CI or headless environments, set a PAT or JWT before starting opencode:
```bash
export SNOWFLAKE_ACCOUNT=myorg-myaccount
export SNOWFLAKE_CORTEX_TOKEN=your-pat-or-jwt
```
:::note
`SNOWFLAKE_CORTEX_TOKEN` accepts a PAT or JWT only β the browser OAuth flow is available via `/connect` only and cannot be configured through an environment variable. `SNOWFLAKE_CORTEX_PAT` is still supported for backward compatibility.
:::
The model catalog is provided automatically. A minimal `opencode.json` is all that's needed:
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"model": "snowflake-cortex/claude-sonnet-4-6",
"small_model": "snowflake-cortex/claude-haiku-4-5"
}
```
---
### Together AI
1. Head over to the [Together AI console](https://api.together.ai), create an account, and click **Add Key**.
2. Run the `/connect` command and search for **Together AI**.
```txt
/connect
```
3. Enter your Together AI API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model like _Kimi K2 Instruct_.
```txt
/models
```
---
### Venice AI
1. Head over to the [Venice AI console](https://venice.ai), create an account, and generate an API key.
2. Run the `/connect` command and search for **Venice AI**.
```txt
/connect
```
3. Enter your Venice AI API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model like _Llama 3.3 70B_.
```txt
/models
```
---
### Vercel AI Gateway
Vercel AI Gateway lets you access models from OpenAI, Anthropic, Google, xAI, and more through a unified endpoint. Models are offered at list price with no markup.
1. Head over to the [Vercel dashboard](https://vercel.com/), navigate to the **AI Gateway** tab, and click **API keys** to create a new API key.
2. Run the `/connect` command and search for **Vercel AI Gateway**.
```txt
/connect
```
3. Enter your Vercel AI Gateway API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model.
```txt
/models
```
You can also customize models through your opencode config. Here's an example of specifying provider routing order.
```json title="opencode.json"
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"vercel": {
"models": {
"anthropic/claude-sonnet-4": {
"options": {
"order": ["anthropic", "vertex"]
}
}
}
}
}
}
```
Some useful routing options:
| Option | Description |
| ------------------- | ---------------------------------------------------- |
| `order` | Provider sequence to try |
| `only` | Restrict to specific providers |
| `zeroDataRetention` | Only use providers with zero data retention policies |
---
### xAI
Two ways to authenticate: a SuperGrok subscription via device-code OAuth or a pay-as-you-go API key from the xAI console.
#### Option A β SuperGrok subscription
1. Run the `/connect` command and search for **xAI**.
```txt
/connect
```
2. Select **SuperGrok Subscription**. OpenCode opens xAI's verification link with the user code pre-populated when supported.
3. Approve the consent screen. If xAI asks for a code, enter the user code displayed by OpenCode. OpenCode polls xAI's token endpoint and stores the resulting OAuth tokens once you approve.
4. Run the `/models` command to select a Grok model.
```txt
/models
```
OpenCode refreshes the OAuth access token automatically. Any Grok or X Premium plan that includes Grok API access works; you do not need a separate `XAI_API_KEY`.
#### Option B β API key
1. Head over to the [xAI console](https://console.x.ai/), create an account, and generate an API key.
2. Run the `/connect` command and search for **xAI**.
```txt
/connect
```
3. Select **Manually enter API Key** and paste your xAI API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model like _Grok Beta_.
```txt
/models
```
---
### Z.AI
1. Head over to the [Z.AI API console](https://z.ai/manage-apikey/apikey-list), create an account, and click **Create a new API key**.
2. Run the `/connect` command and search for **Z.AI**.
```txt
/connect
```
If you are subscribed to the **GLM Coding Plan**, select **Z.AI Coding Plan**.
3. Enter your Z.AI API key.
```txt
β API key
β
β
β enter
```
4. Run the `/models` command to select a model like _GLM-4.7_.
```txt
/models
```
---
### ZenMux
1. Head over to the [ZenMux dashboard](https://zenmux.ai/settings/keys), click **Create API Key**, and copy the key.
2. Run the `/connect` command and search for ZenMux.
```txt
/connect
```
3. Enter the API key for the provider.
```txt
β API key
β
β
β enter
```
4. Many ZenMux models are preloaded by default, run the `/models` command to select the one you want.
```txt
/models
```
You can also add additional models through your opencode config.
```json title="opencode.json" {6}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"zenmux": {
"models": {
"somecoolnewmodel": {}
}
}
}
}
```
---
## Custom provider
To add any **OpenAI-compatible** provider that's not listed in the `/connect` command:
:::tip
You can use any OpenAI-compatible provider with opencode. Most modern AI providers offer OpenAI-compatible APIs.
:::
1. Run the `/connect` command and scroll down to **Other**.
```bash
$ /connect
β Add credential
β
β Select provider
β ...
β β Other
β
```
2. Enter a unique ID for the provider.
```bash
$ /connect
β Add credential
β
β Enter provider id
β myprovider
β
```
:::note
Choose a memorable ID, you'll use this in your config file.
:::
3. Enter your API key for the provider.
```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. Create or update your `opencode.json` file in your project directory:
```json title="opencode.json" ""myprovider"" {5-15}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"myprovider": {
"npm": "@ai-sdk/openai-compatible",
"name": "My AI Provider Display Name",
"options": {
"baseURL": "https://api.myprovider.com/v1"
},
"models": {
"my-model-name": {
"name": "My Model Display Name"
}
}
}
}
}
```
Here are the configuration options:
- **npm**: AI SDK package to use, `@ai-sdk/openai-compatible` for OpenAI-compatible providers (for `/v1/chat/completions`). If your provider/model uses `/v1/responses`, use `@ai-sdk/openai`.
- **name**: Display name in UI.
- **models**: Available models.
- **options.baseURL**: API endpoint URL.
- **options.apiKey**: Optionally set the API key, if not using auth.
- **options.headers**: Optionally set custom headers.
More on the advanced options in the example below.
5. Run the `/models` command and your custom provider and models will appear in the selection list.
---
##### Example
Here's an example setting the `apiKey`, `headers`, and model `limit` options.
```json title="opencode.json" {9,11,17-20}
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"myprovider": {
"npm": "@ai-sdk/openai-compatible",
"name": "My AI Provider Display 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
}
}
}
}
}
}
```
Configuration details:
- **apiKey**: Set using `env` variable syntax, [learn more](/docs/config#env-vars).
- **headers**: Custom headers sent with each request.
- **limit.context**: Maximum input tokens the model accepts.
- **limit.output**: Maximum tokens the model can generate.
The `limit` fields allow OpenCode to understand how much context you have left. Standard providers pull these from models.dev automatically.
---
## Troubleshooting
If you are having trouble with configuring a provider, check the following:
1. **Check the auth setup**: Run `opencode auth list` to see if the credentials
for the provider are added to your config.
This doesn't apply to providers like Amazon Bedrock, that rely on environment variables for their auth.
2. For custom providers, check the opencode config and:
- Make sure the provider ID used in the `/connect` command matches the ID in your opencode config.
- The right npm package is used for the provider. For example, use `@ai-sdk/cerebras` for Cerebras. And for all other OpenAI-compatible providers, use `@ai-sdk/openai-compatible` (for `/v1/chat/completions`); if a model uses `/v1/responses`, use `@ai-sdk/openai`. For mixed setups under one provider, you can override per model via `provider.npm`.
- Check correct API endpoint is used in the `options.baseURL` field.
|