Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/proxy/src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export const CACHED_HEADER = "x-bt-cached";

export const USED_ENDPOINT_HEADER = "x-bt-used-endpoint";

export const OAI_STAINLESS_METHOD_HEADER = "x-stainless-helper-method";

const CACHE_MODES = ["auto", "always", "never"] as const;

// Options to control how the cache key is generated.
Expand Down Expand Up @@ -334,6 +336,13 @@ export async function proxyV1({

let startTime = getCurrentUnixTimestamp();
let spanType: SpanType | undefined = undefined;
// TEMP: support OAI streaming via oai.beta.chat.completions.stream
// openai-node currently overrides the usual stream param to false
const isStainlessStream =
proxyHeaders[OAI_STAINLESS_METHOD_HEADER] === "stream";
if (isStainlessStream && bodyData) {
bodyData.stream = true;
}
const isStreaming = !!bodyData?.stream;

let stream: ReadableStream<Uint8Array> | null = null;
Expand Down