codex-mini, openai responses api #18

Closed
opened 2026-02-16 17:24:52 -05:00 by yindo · 7 comments
Owner

Originally created by @adamdotdevin on GitHub (May 16, 2025).

codex-mini is currently only available through the Responses API, and we only have support for Chat Completions.

obviously, we have to retain support for the completions API since many other providers rely on that shape. but, we need to add support for leveraging the Responses API in cases like this.

i have a branch locally that i'll push in the morning which mostly has this all worked out, but it's not complete and i'm out on vacation all next week if anyone wants to build off of it and finish it up.

Originally created by @adamdotdevin on GitHub (May 16, 2025). codex-mini is currently only available through the Responses API, and we only have support for Chat Completions. obviously, we have to retain support for the completions API since many other providers rely on that shape. but, we need to add support for leveraging the Responses API in cases like this. i have a branch locally that i'll push in the morning which mostly has this all worked out, but it's not complete and i'm out on vacation all next week if anyone wants to build off of it and finish it up.
yindo closed this issue 2026-02-16 17:24:52 -05:00
Author
Owner

@adamdotdevin commented on GitHub (May 16, 2025):

pushed to codex-mini branch. it works on first request, but i'm not building messages back correctly on the second request, didn't have time to dig into it. lmk if anyone wants to pick this up next week, curious how well codex-mini works.

@adamdotdevin commented on GitHub (May 16, 2025): pushed to `codex-mini` branch. it works on first request, but i'm not building messages back correctly on the second request, didn't have time to dig into it. lmk if anyone wants to pick this up next week, curious how well codex-mini works.
Author
Owner

@adamdotdevin commented on GitHub (May 16, 2025):

in that branch i just overwrote the existing openai provider but we'd need to keep it in place for other providers and only use responses API selectively

@adamdotdevin commented on GitHub (May 16, 2025): in that branch i just overwrote the existing openai provider but we'd need to keep it in place for other providers and only use responses API selectively
Author
Owner

@PhantomReactor commented on GitHub (May 17, 2025):

I'll pick this up this

@PhantomReactor commented on GitHub (May 17, 2025): I'll pick this up this
Author
Owner

@jcsmithf22 commented on GitHub (May 18, 2025):

I looked into this a little bit. If using ResponseOutputMessageParam for the assistant message type, you need to provide the message id. That was giving the error

Invalid 'input[2].id': ''. Expected an ID that contains letters, numbers, underscores, or dashes, but this value contained additional characters.

Providing the uuid generated for messages resulted in this error:

Invalid 'input[2].id': '887ced55-262e-4aa5-a768-f4f89d4a94cf'. Expected an ID that begins with 'msg'.

Prepending "msg_" gave this error:

Item with id 'msg_3aedd1f2-015a-476b-9107-9ae51a4e14e8 not found.'

I decided to try the following because it did not require an ID. This worked successfully. (Line 111 in providers/openai.go)

case message.Assistant:
	if msg.Content().String() != "" {
		assistantMsg := responses.ResponseInputItemUnionParam{
			OfMessage: &responses.EasyInputMessageParam{
				Content: responses.EasyInputMessageContentUnionParam{OfString: openai.String(msg.Content().String())},
				Role:    responses.EasyInputMessageRoleAssistant,
			},
			// OfOutputMessage: &responses.ResponseOutputMessageParam{
			// 	ID: "msg_" + msg.ID,
			// 	Content: []responses.ResponseOutputMessageContentUnionParam{{
			// 		OfOutputText: &responses.ResponseOutputTextParam{
			// 			Text: msg.Content().String(),
			// 		},
			// 	}},
			// },
		}
		inputItems = append(inputItems, assistantMsg)
	}

The description for EasyInputMessageParam seems to indicate this is a suitable choice.

A message input to the model with a role indicating instruction following hierarchy. 
Instructions given with the `developer` or `system` role take precedence over 
instructions given with the `user` role. Messages with the `assistant` role are 
presumed to have been generated by the model in previous interactions.
@jcsmithf22 commented on GitHub (May 18, 2025): I looked into this a little bit. If using `ResponseOutputMessageParam` for the assistant message type, you need to provide the message id. That was giving the error ``` Invalid 'input[2].id': ''. Expected an ID that contains letters, numbers, underscores, or dashes, but this value contained additional characters. ``` Providing the uuid generated for messages resulted in this error: ``` Invalid 'input[2].id': '887ced55-262e-4aa5-a768-f4f89d4a94cf'. Expected an ID that begins with 'msg'. ``` Prepending "msg_" gave this error: ``` Item with id 'msg_3aedd1f2-015a-476b-9107-9ae51a4e14e8 not found.' ``` I decided to try the following because it did not require an ID. This worked successfully. (Line 111 in providers/openai.go) ```go case message.Assistant: if msg.Content().String() != "" { assistantMsg := responses.ResponseInputItemUnionParam{ OfMessage: &responses.EasyInputMessageParam{ Content: responses.EasyInputMessageContentUnionParam{OfString: openai.String(msg.Content().String())}, Role: responses.EasyInputMessageRoleAssistant, }, // OfOutputMessage: &responses.ResponseOutputMessageParam{ // ID: "msg_" + msg.ID, // Content: []responses.ResponseOutputMessageContentUnionParam{{ // OfOutputText: &responses.ResponseOutputTextParam{ // Text: msg.Content().String(), // }, // }}, // }, } inputItems = append(inputItems, assistantMsg) } ``` The description for `EasyInputMessageParam` seems to indicate this is a suitable choice. ``` A message input to the model with a role indicating instruction following hierarchy. Instructions given with the `developer` or `system` role take precedence over instructions given with the `user` role. Messages with the `assistant` role are presumed to have been generated by the model in previous interactions. ```
Author
Owner

@PhantomReactor commented on GitHub (May 18, 2025):

@jcsmithf22 i fixed this issue in my fork of this branch. I noticed openai-go library was sending an empty id ("id": "") in the request. This has been fixed in the latest versions of the sdk. I just updated the version and it worked.

@PhantomReactor commented on GitHub (May 18, 2025): @jcsmithf22 i fixed this issue in my fork of this branch. I noticed openai-go library was sending an empty id ("id": "") in the request. This has been fixed in the latest versions of the sdk. I just updated the version and it worked.
Author
Owner

@jcsmithf22 commented on GitHub (May 18, 2025):

@PhantomReactor strangely when I try to update to beta 11 I get an "unknown revision" error

EDIT: I see beta 10 fixes the error, which is what you must have been referring to.

@jcsmithf22 commented on GitHub (May 18, 2025): @PhantomReactor strangely when I try to update to beta 11 I get an "unknown revision" error EDIT: I see beta 10 fixes the error, which is what you must have been referring to.
Author
Owner

@AlexHird commented on GitHub (Jul 27, 2025):

I have the same issue when using codex-mini deployed with azure openai. I might be mistaken but the closed pull request is only for the openai provider?

@AlexHird commented on GitHub (Jul 27, 2025): I have the same issue when using `codex-mini` deployed with azure openai. I might be mistaken but the closed pull request is only for the `openai` provider?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#18