diff --git a/.changeset/gold-hounds-relate.md b/.changeset/gold-hounds-relate.md new file mode 100644 index 00000000..32d5f2e3 --- /dev/null +++ b/.changeset/gold-hounds-relate.md @@ -0,0 +1,5 @@ +--- +"@empiricalrun/ai": patch +--- + +fix: openai errors not getting captured diff --git a/packages/ai/src/providers/openai/index.ts b/packages/ai/src/providers/openai/index.ts index 12d3ab80..0ebcac9a 100644 --- a/packages/ai/src/providers/openai/index.ts +++ b/packages/ai/src/providers/openai/index.ts @@ -36,7 +36,7 @@ const createChatCompletion: ICreateChatCompletion = async (body) => { retry(err); throw err; } - return err; + throw err; }); }, { @@ -48,7 +48,7 @@ const createChatCompletion: ICreateChatCompletion = async (body) => { } catch (err) { throw new AIError( AIErrorEnum.FAILED_CHAT_COMPLETION, - `failed chat completion for model openai ${body.model} with error code: ${(err as OpenAI.ErrorObject).code}`, + `failed chat completion for model openai "${body.model}" with the error message: ${(err as any)?.error?.message}`, ); } };