(client, request3, options)
| 44539 | var components = __importStar(require_components()); |
| 44540 | var errors = __importStar(require_errors2()); |
| 44541 | async function chatComplete(client, request3, options) { |
| 44542 | const parsed = (0, schemas_js_1.safeParse)(request3, (value) => components.ChatCompletionRequest$outboundSchema.parse(value), "Input validation failed"); |
| 44543 | if (!parsed.ok) { |
| 44544 | return parsed; |
| 44545 | } |
| 44546 | const payload = parsed.value; |
| 44547 | const body = (0, encodings_js_1.encodeJSON)("body", payload, { explode: true }); |
| 44548 | const path5 = (0, url_js_1.pathToFunc)("/v1/chat/completions")(); |
| 44549 | const headers = new Headers({ |
| 44550 | "Content-Type": "application/json", |
| 44551 | Accept: "application/json" |
| 44552 | }); |
| 44553 | const secConfig = await (0, security_js_1.extractSecurity)(client._options.apiKey); |
| 44554 | const securityInput = secConfig == null ? {} : { apiKey: secConfig }; |
| 44555 | const requestSecurity = (0, security_js_1.resolveGlobalSecurity)(securityInput); |
| 44556 | const context = { |
| 44557 | operationID: "chat_completion_v1_chat_completions_post", |
| 44558 | oAuth2Scopes: [], |
| 44559 | resolvedSecurity: requestSecurity, |
| 44560 | securitySource: client._options.apiKey, |
| 44561 | retryConfig: (options === null || options === void 0 ? void 0 : options.retries) || client._options.retryConfig || { strategy: "none" }, |
| 44562 | retryCodes: (options === null || options === void 0 ? void 0 : options.retryCodes) || ["429", "500", "502", "503", "504"] |
| 44563 | }; |
| 44564 | const requestRes = client._createRequest(context, { |
| 44565 | security: requestSecurity, |
| 44566 | method: "POST", |
| 44567 | path: path5, |
| 44568 | headers, |
| 44569 | body, |
| 44570 | timeoutMs: (options === null || options === void 0 ? void 0 : options.timeoutMs) || client._options.timeoutMs || -1 |
| 44571 | }, options); |
| 44572 | if (!requestRes.ok) { |
| 44573 | return requestRes; |
| 44574 | } |
| 44575 | const req = requestRes.value; |
| 44576 | const doResult = await client._do(req, { |
| 44577 | context, |
| 44578 | errorCodes: ["422", "4XX", "5XX"], |
| 44579 | retryConfig: context.retryConfig, |
| 44580 | retryCodes: context.retryCodes |
| 44581 | }); |
| 44582 | if (!doResult.ok) { |
| 44583 | return doResult; |
| 44584 | } |
| 44585 | const response = doResult.value; |
| 44586 | const responseFields = { |
| 44587 | HttpMeta: { Response: response, Request: req } |
| 44588 | }; |
| 44589 | const [result] = await M5.match(M5.json(200, components.ChatCompletionResponse$inboundSchema), M5.jsonErr(422, errors.HTTPValidationError$inboundSchema), M5.fail(["4XX", "5XX"]))(response, { extraFields: responseFields }); |
| 44590 | if (!result.ok) { |
| 44591 | return result; |
| 44592 | } |
| 44593 | return result; |
| 44594 | } |
| 44595 | } |
| 44596 | }); |
| 44597 |
nothing calls this directly
no test coverage detected
searching dependent graphs…