@@ -66,11 +66,6 @@ import {
6666import { isEmptyObj } from './internal/utils/values' ;
6767
6868export interface ClientOptions {
69- /**
70- * Defaults to process.env['OPENCODE_API_KEY'].
71- */
72- apiKey ?: string | null | undefined ;
73-
7469 /**
7570 * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
7671 *
@@ -142,8 +137,6 @@ export interface ClientOptions {
142137 * API Client for interfacing with the Opencode API.
143138 */
144139export class Opencode {
145- apiKey : string | null ;
146-
147140 baseURL : string ;
148141 maxRetries : number ;
149142 timeout : number ;
@@ -159,7 +152,6 @@ export class Opencode {
159152 /**
160153 * API Client for interfacing with the Opencode API.
161154 *
162- * @param {string | null | undefined } [opts.apiKey=process.env['OPENCODE_API_KEY'] ?? null]
163155 * @param {string } [opts.baseURL=process.env['OPENCODE_BASE_URL'] ?? http://localhost:54321] - Override the default base URL for the API.
164156 * @param {number } [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
165157 * @param {MergedRequestInit } [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
@@ -168,13 +160,8 @@ export class Opencode {
168160 * @param {HeadersLike } opts.defaultHeaders - Default headers to include with every request to the API.
169161 * @param {Record<string, string | undefined> } opts.defaultQuery - Default query parameters to include with every request to the API.
170162 */
171- constructor ( {
172- baseURL = readEnv ( 'OPENCODE_BASE_URL' ) ,
173- apiKey = readEnv ( 'OPENCODE_API_KEY' ) ?? null ,
174- ...opts
175- } : ClientOptions = { } ) {
163+ constructor ( { baseURL = readEnv ( 'OPENCODE_BASE_URL' ) , ...opts } : ClientOptions = { } ) {
176164 const options : ClientOptions = {
177- apiKey,
178165 ...opts ,
179166 baseURL : baseURL || `http://localhost:54321` ,
180167 } ;
@@ -195,8 +182,6 @@ export class Opencode {
195182 this . #encoder = Opts . FallbackEncoder ;
196183
197184 this . _options = options ;
198-
199- this . apiKey = apiKey ;
200185 }
201186
202187 /**
@@ -212,7 +197,6 @@ export class Opencode {
212197 logLevel : this . logLevel ,
213198 fetch : this . fetch ,
214199 fetchOptions : this . fetchOptions ,
215- apiKey : this . apiKey ,
216200 ...options ,
217201 } ) ;
218202 }
@@ -229,23 +213,7 @@ export class Opencode {
229213 }
230214
231215 protected validateHeaders ( { values, nulls } : NullableHeaders ) {
232- if ( this . apiKey && values . get ( 'authorization' ) ) {
233- return ;
234- }
235- if ( nulls . has ( 'authorization' ) ) {
236- return ;
237- }
238-
239- throw new Error (
240- 'Could not resolve authentication method. Expected the apiKey to be set. Or for the "Authorization" headers to be explicitly omitted' ,
241- ) ;
242- }
243-
244- protected authHeaders ( opts : FinalRequestOptions ) : NullableHeaders | undefined {
245- if ( this . apiKey == null ) {
246- return undefined ;
247- }
248- return buildHeaders ( [ { Authorization : `Bearer ${ this . apiKey } ` } ] ) ;
216+ return ;
249217 }
250218
251219 /**
@@ -683,7 +651,6 @@ export class Opencode {
683651 ...( options . timeout ? { 'X-Stainless-Timeout' : String ( Math . trunc ( options . timeout / 1000 ) ) } : { } ) ,
684652 ...getPlatformHeaders ( ) ,
685653 } ,
686- this . authHeaders ( options ) ,
687654 this . _options . defaultHeaders ,
688655 bodyHeaders ,
689656 options . headers ,
0 commit comments