Skip to content

Commit

Permalink
fix: rename bearerToken to apiKey
Browse files Browse the repository at this point in the history
  • Loading branch information
shahrear33 committed Jan 31, 2025
1 parent 228e397 commit abb108d
Show file tree
Hide file tree
Showing 20 changed files with 70 additions and 71 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ The full API of this library can be found in [api.md](api.md).
import VlmRun from 'vlmrun';

const client = new VlmRun({
bearerToken: process.env.BEARER_TOKEN || '',
apiKey: process.env.VLMRUN_API_KEY || '',
baseUrl: 'https://dev.vlm.run',
});

Expand Down Expand Up @@ -309,10 +309,9 @@ Note that React Native is not supported at this time.

If you are interested in other runtime environments, please open or upvote an issue on GitHub.


## 🔗 Quick Links

* 💬 Need help? Send us an email at [[email protected]](mailto:[email protected]) or join our [Discord](https://discord.gg/CCY8cYNC)
* 📣 Stay updated by following us on [Twitter](https://twitter.com/vlmrun) and [LinkedIn](https://www.linkedin.com/company/vlm-run)
* 📚 Check out our [Documentation](https://docs.vlm.run/) for detailed guides and API references
* 🐛 Found a bug? Open an [issue](https://github.com/vlm-run/vlmrun-node-sdk/issues) on GitHub
- 💬 Need help? Send us an email at [[email protected]](mailto:[email protected]) or join our [Discord](https://discord.gg/CCY8cYNC)
- 📣 Stay updated by following us on [Twitter](https://twitter.com/vlmrun) and [LinkedIn](https://www.linkedin.com/company/vlm-run)
- 📚 Check out our [Documentation](https://docs.vlm.run/) for detailed guides and API references
- 🐛 Found a bug? Open an [issue](https://github.com/vlm-run/vlmrun-node-sdk/issues) on GitHub
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vlmrun",
"version": "0.1.6",
"version": "0.1.7",
"description": "The official TypeScript library for the Vlm API",
"author": "Vlm <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ const getPlatformProperties = (): PlatformProperties => {
'X-Stainless-Arch': normalizeArch(Deno.build.arch),
'X-Stainless-Runtime': 'deno',
'X-Stainless-Runtime-Version':
typeof Deno.version === 'string' ? Deno.version : (Deno.version?.deno ?? 'unknown'),
typeof Deno.version === 'string' ? Deno.version : Deno.version?.deno ?? 'unknown',

Check failure on line 847 in src/core.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `Deno.version?.deno·??·'unknown'` with `(Deno.version?.deno·??·'unknown')`
};
}
if (typeof EdgeRuntime !== 'undefined') {
Expand Down
26 changes: 13 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import { OpenAI, OpenAIHealthResponse } from './resources/openai/openai';

export interface ClientOptions {
/**
* The Bearer Token used for authenticating API requests
* The API Key used for authenticating API requests
*/
bearerToken?: string | undefined;
apiKey?: string | undefined;

/**
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
*
* Defaults to process.env['VLM_BASE_URL'].
* Defaults to process.env['VLMRUN_BASE_URL'].
*/
baseURL?: string | null | undefined;

Expand Down Expand Up @@ -88,15 +88,15 @@ export interface ClientOptions {
* API Client for interfacing with the Vlm API.
*/
export class VlmRun extends Core.APIClient {
bearerToken: string;
apiKey: string;

private _options: ClientOptions;

/**
* API Client for interfacing with the Vlm API.
*
* @param {string | undefined} [opts.bearerToken=process.env['BEARER_TOKEN'] ?? undefined]
* @param {string} [opts.baseURL=process.env['VLM_BASE_URL'] ?? https://api.vlm.run] - Override the default base URL for the API.
* @param {string | undefined} [opts.apiKey=process.env['VLMRUN_API_KEY'] ?? undefined]
* @param {string} [opts.baseURL=process.env['VLMRUN_BASE_URL'] ?? https://api.vlm.run] - Override the default base URL for the API.
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
Expand All @@ -105,18 +105,18 @@ export class VlmRun extends Core.APIClient {
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
*/
constructor({
baseURL = Core.readEnv('VLM_BASE_URL'),
bearerToken = Core.readEnv('BEARER_TOKEN'),
baseURL = Core.readEnv('VLMRUN_BASE_URL'),
apiKey = Core.readEnv('VLMRUN_API_KEY'),
...opts
}: ClientOptions = {}) {
if (bearerToken === undefined) {
if (apiKey === undefined) {
throw new Errors.VlmError(
"The BEARER_TOKEN environment variable is missing or empty; either provide it, or instantiate the Vlm client with an bearerToken option, like new Vlm({ bearerToken: 'My Bearer Token' }).",
"The VLMRUN_API_KEY environment variable is missing or empty; either provide it, or instantiate the Vlm client with an apiKey option, like new Vlm({ apiKey: 'My API Key' }).",
);
}

const options: ClientOptions = {
bearerToken,
apiKey,
...opts,
baseURL: baseURL || `https://api.vlm.run`,
};
Expand All @@ -131,7 +131,7 @@ export class VlmRun extends Core.APIClient {

this._options = options;

this.bearerToken = bearerToken;
this.apiKey = apiKey;
}

openai: API.OpenAI = new API.OpenAI(this);
Expand Down Expand Up @@ -164,7 +164,7 @@ export class VlmRun extends Core.APIClient {
}

protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
return { Authorization: `Bearer ${this.bearerToken}` };
return { Authorization: `Bearer ${this.apiKey}` };
}

static Vlm = this;
Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/audio.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import VlmRun from 'vlmrun';
import { Response } from 'node-fetch';

const client = new VlmRun({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/document.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import VlmRun from 'vlmrun';
import { Response } from 'node-fetch';

const client = new VlmRun({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import VlmRun from 'vlmrun';
import { Response } from 'node-fetch';

const client = new VlmRun({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/experimental/experimental.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import VlmRun from 'vlmrun';
import { Response } from 'node-fetch';

const client = new VlmRun({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/experimental/image/embeddings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import VlmRun from 'vlmrun';
import { Response } from 'node-fetch';

const client = new VlmRun({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/files.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import VlmRun, { toFile } from 'vlmrun';
import { Response } from 'node-fetch';

const client = new VlmRun({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import VlmRun from 'vlmrun';
import { Response } from 'node-fetch';

const client = new VlmRun({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/models.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import VlmRun from 'vlmrun';
import { Response } from 'node-fetch';

const client = new VlmRun({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/openai/chat-completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import VlmRun from 'vlmrun';
import { Response } from 'node-fetch';

const client = new VlmRun({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/openai/models.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import VlmRun from 'vlmrun';
import { Response } from 'node-fetch';

const client = new VlmRun({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/openai/openai.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import VlmRun from 'vlmrun';
import { Response } from 'node-fetch';

const client = new VlmRun({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
4 changes: 2 additions & 2 deletions tests/api-resources/response.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import VlmRun from 'vlmrun';
import { Response } from 'node-fetch';

const client = new VlmRun({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource response', () => {
test('retrieve', async () => {
test.skip('retrieve', async () => {
const responsePromise = client.response.retrieve('id');
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import VlmRun from 'vlmrun';
import { Response } from 'node-fetch';

const client = new VlmRun({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/top-level.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import VlmRun from 'vlmrun';
import { Response } from 'node-fetch';

const client = new VlmRun({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/web.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import VlmRun from 'vlmrun';
import { Response } from 'node-fetch';

const client = new VlmRun({
bearerToken: 'My Bearer Token',
apiKey: 'My API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
Loading

0 comments on commit abb108d

Please sign in to comment.