MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / completePrompt

Method completePrompt

src/api/providers/openai-codex.ts:1157–1262  ·  view source on GitHub ↗
(prompt: string)

Source from the content-addressed store, hash-verified

1155 }
1156
1157 async completePrompt(prompt: string): Promise<string> {
1158 this.abortController = new AbortController()
1159
1160 try {
1161 const model = this.getModel()
1162
1163 // Get access token
1164 const accessToken = await openAiCodexOAuthManager.getAccessToken()
1165 if (!accessToken) {
1166 throw new Error(
1167 t("common:errors.openAiCodex.notAuthenticated", {
1168 defaultValue:
1169 "Not authenticated with OpenAI Codex. Please sign in using the OpenAI Codex OAuth flow.",
1170 }),
1171 )
1172 }
1173
1174 const reasoningEffort = this.getReasoningEffort(model)
1175
1176 const requestBody: any = {
1177 model: model.id,
1178 input: [
1179 {
1180 role: "user",
1181 content: [{ type: "input_text", text: prompt }],
1182 },
1183 ],
1184 stream: false,
1185 store: false,
1186 ...(reasoningEffort ? { include: ["reasoning.encrypted_content"] } : {}),
1187 }
1188
1189 if (reasoningEffort) {
1190 requestBody.reasoning = {
1191 effort: reasoningEffort,
1192 summary: "auto" as const,
1193 }
1194 }
1195
1196 const url = `${CODEX_API_BASE_URL}/responses`
1197
1198 // Get ChatGPT account ID for organization subscriptions
1199 const accountId = await openAiCodexOAuthManager.getAccountId()
1200
1201 // Build headers with required Codex-specific fields
1202 const headers: Record<string, string> = {
1203 "Content-Type": "application/json",
1204 Authorization: `Bearer ${accessToken}`,
1205 originator: "zoo-code",
1206 session_id: this.sessionId,
1207 "User-Agent": `zoo-code/${Package.version} (${os.platform()} ${os.release()}; ${os.arch()}) node/${process.version.slice(1)}`,
1208 }
1209
1210 // Add ChatGPT-Account-Id if available
1211 if (accountId) {
1212 headers["ChatGPT-Account-Id"] = accountId
1213 }
1214

Callers

nothing calls this directly

Calls 8

getModelMethod · 0.95
getReasoningEffortMethod · 0.95
tFunction · 0.90
getAccessTokenMethod · 0.80
getAccountIdMethod · 0.80
textMethod · 0.80
captureExceptionMethod · 0.65
StringInterface · 0.50

Tested by

no test coverage detected