Skip to content

Commit

Permalink
Add returnRawResponse to AI binding options
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaquinGimenez1 committed Jan 22, 2025
1 parent deec614 commit 3a48e2a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/cloudflare/internal/ai-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export type SessionOptions = {

export type AiOptions = {
gateway?: GatewayOptions;

/** If true it will return a Response object */
returnRawResponse?: boolean;
prefix?: string;
extraHeaders?: object;
/*
Expand Down Expand Up @@ -142,6 +143,10 @@ export class Ai {
this.aiGatewayLogId = res.headers.get('cf-aig-log-id');
this.lastRequestHttpStatusCode = res.status;

if (this.options.returnRawResponse) {
return res;
}

if (!res.ok) {
throw await this._parseError(res);
}
Expand Down

0 comments on commit 3a48e2a

Please # to comment.