cloudflare/cloudflare-typescript

Public

mirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v6.3.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

tests/api-resources/ai/ai.test.ts

33lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import Cloudflare from 'cloudflare';
4import { Response } from 'node-fetch';
5
6const client = new Cloudflare({
7 apiKey: '144c9defac04969c7bfad8efaa8ea194',
8 apiEmail: 'user@example.com',
9 baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
10});
11
12describe('resource ai', () => {
13 test('run: only required params', async () => {
14 const responsePromise = client.ai.run('model_name', {
15 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
16 text: 'x',
17 });
18 const rawResponse = await responsePromise.asResponse();
19 expect(rawResponse).toBeInstanceOf(Response);
20 const response = await responsePromise;
21 expect(response).not.toBeInstanceOf(Response);
22 const dataAndResponse = await responsePromise.withResponse();
23 expect(dataAndResponse.data).toBe(response);
24 expect(dataAndResponse.response).toBe(rawResponse);
25 });
26
27 test('run: required and optional params', async () => {
28 const response = await client.ai.run('model_name', {
29 account_id: '023e105f4ecef8ad9ca31a8372d0c353',
30 text: 'x',
31 });
32 });
33});
34