Skip to content

Add embeddings, models, moderations, and image generation endpoints#2

Open
beta-devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1775584687-add-openai-endpoints
Open

Add embeddings, models, moderations, and image generation endpoints#2
beta-devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1775584687-add-openai-endpoints

Conversation

@beta-devin-ai-integration

@beta-devin-ai-integration beta-devin-ai-integration Bot commented Apr 7, 2026

Copy link
Copy Markdown

Summary

Adds support for additional OpenAI API endpoints beyond chat completions:

  • Embeddings (POST /v1/embeddings) via createEmbedding()
  • List Models (GET /v1/models) via listModels()
  • Retrieve Model (GET /v1/models/{model}) via retrieveModel()
  • Moderations (POST /v1/moderations) via createModeration()
  • Image Generation (POST /v1/images/generations) via createImage()

Also introduces a makeRequest() internal helper for GET requests (the existing makeCall() only supports POST with a body), fixes a double-free bug in chat(), and updates the README with an API reference section.

Bugfix: chat() had both defer req.deinit() and an explicit req.deinit() on the error path, causing a double-free. The explicit call is removed since defer already handles cleanup.

Review & Testing Checklist for Human

  • Moderation category fields are incomplete: ModerationCategories and ModerationCategoryScores are missing the illicit and illicit/violent fields that the OpenAI API now returns. Since ignore_unknown_fields = true is used for deserialization this won't crash, but those categories are silently dropped. Decide whether to add them (with defaults) or leave as-is.
  • EmbeddingPayload.input only accepts a single string: The OpenAI embeddings API also accepts []string for batch embedding. This is a functional limitation worth considering.
  • Integration test against real API: There are no tests in this repo. Verify that the new response types deserialize correctly against actual OpenAI API responses, particularly Embedding.embedding: []f64 and the moderation structs with @"slash/separated" field names.
  • Double-free fix correctness: Confirm that the chat() error path change (removing explicit req.deinit(), relying on defer) is correct — the defer req.deinit() on line 352 already covers cleanup.

Notes

  • makeRequest and makeCall share duplicated URI/header construction logic. Could be refactored but kept separate to match the existing code style.
  • Built and verified with Zig 0.13.0 (the version the repo targets). Zig 0.14.0 requires build.zig.zon format changes that are out of scope.
  • Audio endpoints (transcription, translation, speech) are not included as they require multipart form encoding, which is a larger change. The Responses API is also excluded due to its complexity.

Link to Devin session: https://app.beta.devin.ai/sessions/6adf11eb1dc24b5692382ef0591ea15a
Requested by: @FOLLGAD


Staging: Open in Devin

- Add createEmbedding() for POST /v1/embeddings
- Add listModels() for GET /v1/models
- Add retrieveModel() for GET /v1/models/{model}
- Add createModeration() for POST /v1/moderations
- Add createImage() for POST /v1/images/generations
- Add makeRequest() helper for GET requests
- Fix double-free bug in chat() error path
- Update README with API reference for all endpoints

Co-Authored-By: ahlback.emil+coggitgrant <me@emil.zip>
@beta-devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@beta-devin-ai-integration beta-devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Staging: Open in Devin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant