Skip to content

Conversation

@HavenDV
Copy link
Contributor

@HavenDV HavenDV commented Sep 19, 2025

Summary by CodeRabbit

  • New Features

    • Added endpoints to view available credits, total spend, average daily spend, and spend-commit details.
    • Introduced a batch results endpoint that returns generated results (including images and prompts).
    • Expanded magic prompt version support.
  • Refactor

    • Replaced the batch status endpoint with a results-focused endpoint; responses now return a results list instead of a file URL.
  • Documentation

    • Updated descriptions and examples to reflect results-based responses and clarified aspect ratio usage.
    • Clarified API key authentication header name and usage.

@coderabbitai
Copy link

coderabbitai bot commented Sep 19, 2025

Walkthrough

The OpenAPI spec at src/libs/Ideogram/openapi.yaml adds two management GET endpoints for credits and spend commits, replaces the internal batch status path with a results-based endpoint, introduces several new response schemas, updates SamplingRequestParams.aspect_ratio, expands MagicPromptVersionEnum, and refines the ApiKeyAuth security scheme.

Changes

Cohort / File(s) Change summary
Management APIs (credits and spend commits)
src/libs/Ideogram/openapi.yaml
Added GET /manage/api/credits (GetUserCreditsResponse) and GET /manage/api/spend_commit (SpendCommitInfoResponse); both require BearerAuth and include new schemas for credits and spend-commit details.
Internal batch results overhaul
src/libs/Ideogram/openapi.yaml
Replaced /internal/batch/status/{job_id} with /internal/batch/get-maybe-batch-results/{job_id}; response renamed to InternalBatchResultsResponse with results array replacing tfrecord_url; new inner result schema includes image_url and prompt; descriptions/examples updated.
Schema additions and renames
src/libs/Ideogram/openapi.yaml
Added GetUserCreditsResponse, SpendCommitInfo, SpendCommitInfoResponse, InternalBatchResultsResponse, InternalBatchResultsResponse_results_inner; removed/renamed InternalBatchStatusResponse references.
Sampling params adjustment
src/libs/Ideogram/openapi.yaml
SamplingRequestParams.aspect_ratio now wraps AspectRatioV3 via allOf with example 1x1; InternalBatchRequest example updated accordingly.
Enum expansion
src/libs/Ideogram/openapi.yaml
MagicPromptVersionEnum gains value V_0_8.
Security scheme refinement
src/libs/Ideogram/openapi.yaml
ApiKeyAuth now explicitly uses header name Api-Key, adds description and x-apikeyInfoFunc; clarified usage text.
Documentation tweaks
src/libs/Ideogram/openapi.yaml
Removed TFRecord references from batch docs; updated 200 response descriptions to reflect results-based responses; operationId and controller mappings aligned.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant API as Ideogram API
  participant Auth as BearerAuth

  rect rgba(230,245,255,0.5)
  note over C,API: Retrieve user credit metrics
  C->>API: GET /manage/api/credits
  API->>Auth: Validate token
  Auth-->>API: OK
  API-->>C: 200 GetUserCreditsResponse
  end

  rect rgba(230,245,255,0.5)
  note over C,API: Retrieve spend-commit info
  C->>API: GET /manage/api/spend_commit
  API->>Auth: Validate token
  Auth-->>API: OK
  API-->>C: 200 SpendCommitInfoResponse (commits[])
  end
Loading
sequenceDiagram
  autonumber
  participant Client
  participant API as Ideogram API
  participant Batch as Batch Service

  rect rgba(240,255,240,0.6)
  note over Client,API: Fetch batch results (replaces status/tfrecord)
  Client->>API: GET /internal/batch/get-maybe-batch-results/{job_id}
  API->>Batch: Query job status/results
  alt Job finished
    Batch-->>API: job_status=done, results[]
    API-->>Client: 200 InternalBatchResultsResponse (results[])
  else Job running
    Batch-->>API: job_status=in_progress
    API-->>Client: 200 InternalBatchResultsResponse (no/partial results)
  end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

A rabbit taps the spec with glee,
“Credits here, and commits for me!”
No TFRecord to chase today,
Just tidy results to hop our way.
New magic whispers V_0_8,
Headers crisp—Api-Key’s great.
Thump-thump: ship it, fate! 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title 'feat:@coderabbitai' is essentially a tag/mention and does not describe the changes made in this PR to the OpenAPI specification. It fails to summarize the primary modifications (e.g., added manage/credits and spend_commit endpoints, renamed internal batch response, and data-model changes). Because the title is non-descriptive, I cannot determine the main change from the title alone. Please update the PR title to a concise, descriptive sentence that highlights the most important change and the affected area (for example: "feat(openapi): add manage/credits and spend_commit endpoints; change internal batch to return results array"). A shorter alternative would be "feat(openapi): add credits APIs and switch batch TFRecord to results". After renaming, reviewers will be able to understand the PR purpose at a glance.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bot/update-openapi_202509190140

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot enabled auto-merge September 19, 2025 01:41
@github-actions github-actions bot merged commit d8e7ea6 into main Sep 19, 2025
3 of 4 checks passed
@github-actions github-actions bot deleted the bot/update-openapi_202509190140 branch September 19, 2025 01:42
@coderabbitai coderabbitai bot changed the title feat:@coderabbitai feat:OpenAPI: mgmt credits/spend endpoints, results endpoint, auth changes Sep 19, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (10)
src/libs/Ideogram/openapi.yaml (10)

183-183: Fix typos: “Evalution” → “Evaluation”.

There are multiple user‑facing misspellings of “Evaluation” around the batch endpoints. Please correct across this path group to avoid leaking typos to SDKs/docs.

Apply where applicable:

- summary: Initiate Batch Magic Prompt Evalution
+ summary: Initiate Batch Magic Prompt Evaluation

And similarly in descriptions/errors that still read “evalution”.


209-239: Endpoint naming and status semantics for results retrieval.

“get-maybe-batch-results” is awkward and couples verb+condition into the path. Prefer a resource‑oriented path and 202 when pending.

Proposed shape:

- '/internal/batch/get-maybe-batch-results/{job_id}':
+ '/internal/batch/{job_id}/results':
   get:
-    summary: Get Batch Magic Prompt Job Results if available.
+    summary: Get batch job results
-    description: "Gets the results of a batch magic prompt job if available.\n"
+    description: "Gets results for a batch magic prompt job. Returns 202 if results are not ready."
     responses:
-      '200':
-        description: Batch magic prompt job results if available.
+      '200':
+        description: Results ready.
         content:
           application/json:
             schema:
               $ref: '#/components/schemas/InternalBatchResultsResponse'
+      '202':
+        description: Results not ready yet.

If you keep the existing path, consider at least adding the 202 response.


219-224: Tighten parameter docs with examples and constraints.

Add an example for job_id and optionally a format/pattern (e.g., UUID/Base64) to improve client generation and validation.

       - name: job_id
         in: path
-        description: The ID of the batch job to check results for
+        description: The ID of the batch job to check results for. Expected to be a URL‑safe Base64 encoded UUID.
         required: true
         style: simple
         schema:
-          type: string
+          type: string
+          example: JRPVD7jWR1aTBYiJ0UFVOg==

371-410: Query param types for dates and examples.

  • start_date/end_date are documented as “dates” but typed as date‑time. If you only need calendar days, use format: date; otherwise specify timezone expectations. Also add examples and clarify inclusivity.
-        - name: start_date
+        - name: start_date
           in: query
-          description: Start date to look back for calculating average daily spend and other metrics
+          description: Start date (inclusive) used to compute spend metrics. If a time component is provided, it will be interpreted in UTC.
           required: true
           schema:
-            type: string
-            format: date-time
+            type: string
+            format: date-time
+            example: '2025-01-01T00:00:00Z'
         - name: end_date
           in: query
-          description: 'Inclusive end date to look back for calculating average daily spend and other metrics. If not provided, the current date will be used.'
+          description: 'Inclusive end timestamp used to compute spend metrics. Defaults to current time (UTC) if omitted.'
           schema:
             type: string
             format: date-time
+            example: '2025-09-19T23:59:59Z'
+        - name: organization_id
+          example: JRPVD7jWR1aTBYiJ0UFVOg==

If day‑level granularity is sufficient, switch both to format: date.


1938-1954: Strengthen result schema: job_status enum, image URL format, and better examples.

  • Make job_status an enum for predictable client code.
  • Enforce image_url as uri and provide a realistic example.
     properties:
       job_status:
         title: job_status
-        type: string
-        description: The status of the batch generation job.
-        example: COMPLETE
+        type: string
+        description: The status of the batch generation job.
+        enum: [PENDING, RUNNING, COMPLETE, FAILED]
+        example: COMPLETE
       results:
         title: results
         type: array
         items:
           $ref: '#/components/schemas/InternalBatchResultsResponse_results_inner'
         description: 'The batch generation results, with each entry containing a prompt and its corresponding image URL.'
@@
   example:
     job_status: COMPLETE
     results:
-      - image_url: image_url
+      - image_url: https://ideogram.ai/api/images/direct/abc123
         prompt: a cat
-      - image_url: image_url
+      - image_url: https://ideogram.ai/api/images/direct/def456
         prompt: a cat

Also applies to: 1956-1961


2895-2912: Rename inner type and add URL format to improve SDK ergonomics.

Generator‑style name “InternalBatchResultsResponse_results_inner” is noisy. Consider a reusable, clear name and enforce URI format.

- InternalBatchResultsResponse_results_inner:
+ BatchResultItem:
   title: InternalBatchResultsResponse_results_inner
@@
     image_url:
       title: image_url
-      type: string
+      type: string
+      format: uri
       description: The URL of the generated image.
-  example:
-    image_url: image_url
+  example:
+    image_url: https://ideogram.ai/api/images/direct/abc123
     prompt: a cat

Follow up: update the array item $ref to point to BatchResultItem.


1882-1884: Outdated cross‑reference to deprecated status endpoint.

Description still says “for /internal/batch/status GET request”. Update to reference the new results endpoint.

-      description: A response for batch magic prompt evalution containing relavent information for /internal/batch/status GET request to find out if the batch generation has completed.
+      description: A response containing information necessary to query batch results via GET /internal/batch/{job_id}/results.

371-410: Security model consistency: internal vs manage.

/manage endpoints correctly require BearerAuth. The /internal/batch endpoints inherit global ApiKeyAuth only—verify this is intended for “internal” surfaces, or add explicit security (e.g., Bearer + feature flag).

If these must be shielded, add:

   get:
+    security:
+      - BearerAuth: []

Operationally, also gate on server‑side feature flags.

Also applies to: 434-469, 2925-2927


2317-2339: Consider requiring available_credits or documenting when it’s absent.

available_credits is optional but will be consumed by clients. Either mark it required or document nullability/absence semantics.

-  required:
-    - average_daily_spend
-    - total_spend
+  required:
+    - average_daily_spend
+    - total_spend
+    # consider: available_credits

If it can be unavailable (e.g., metered‑only orgs), state that explicitly.


347-370: Path naming consistency: prefer hyphens or nouns over underscores.

You use underscores in /manage/api/add_credits and /manage/api/spend_commit, while most other paths are hyphenated or noun‑based. Standardize for API polish.

Examples:

  • /manage/api/add-credits
  • /manage/api/spend-commit

Also applies to: 371-410, 434-469

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ea98666 and 4ff6136.

⛔ Files ignored due to path filters (21)
  • src/libs/Ideogram/Generated/Ideogram.BatchClient.GetMaybeBatchResults.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.BatchClient.PostBatch.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.IBatchClient.GetMaybeBatchResults.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.IBatchClient.PostBatch.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.IManageClient.GetUserCredits.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.IManageClient.GetUserSpendCommitInfo.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.JsonSerializerContextTypes.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.ManageClient.GetUserCredits.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.ManageClient.GetUserSpendCommitInfo.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.Models.GetUserCreditsResponse.Json.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.Models.GetUserCreditsResponse.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.Models.InternalBatchResultsResponse.Json.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.Models.InternalBatchResultsResponse.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.Models.InternalBatchResultsResponseResultsInner.Json.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.Models.InternalBatchResultsResponseResultsInner.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.Models.MagicPromptVersionEnum.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.Models.SamplingRequestParams.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.Models.SpendCommitInfo.Json.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.Models.SpendCommitInfo.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.Models.SpendCommitInfoResponse.Json.g.cs is excluded by !**/generated/**
  • src/libs/Ideogram/Generated/Ideogram.Models.SpendCommitInfoResponse.g.cs is excluded by !**/generated/**
📒 Files selected for processing (1)
  • src/libs/Ideogram/openapi.yaml (12 hunks)
🔇 Additional comments (2)
src/libs/Ideogram/openapi.yaml (2)

1890-1894: Aspect ratio wrapper looks good; examples aligned to V3 values.

No issues; the allOf wrapper plus example 1x1 matches AspectRatioV3.

Please confirm downstream generators (e.g., fern/openapi‑typescript) still render a single union type for aspect_ratio with this wrapper.

Also applies to: 1926-1936


2915-2919: Auth scheme doc improvement looks good.

Explicit header name and info func are helpful; examples elsewhere already use Api-Key. No action needed.

Comment on lines +434 to +469
get:
tags:
- manage
summary: Retrieve user spend commit information
operationId: get_user_spend_commit_info
parameters:
- name: organization_id
in: query
description: Base64 encoded organization ID to filter spend commit information for a specific organization
required: true
schema:
type: string
responses:
'200':
description: User spend commit information retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/SpendCommitInfoResponse'
example:
commits:
- commit_spend_balance:
currency_code: USD
amount: 7500
commit_amount:
currency_code: USD
amount: 10000
commit_start_date: '2025-01-01'
commit_end_date: '2025-12-31T23:59:59.0000000+00:00'
'401':
description: Not authorized
'403':
description: Not authorized
security:
- BearerAuth: [ ]
x-openapi-router-controller: external_api.generated.openapi.controllers.manage_controller
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Spend commit example uses inconsistent date formats.

commit_start_date is schema format: date-time but example is date‑only. Align to date‑time.

-                    commit_start_date: '2025-01-01'
+                    commit_start_date: '2025-01-01T00:00:00Z'

Also consider adding timezone note in the endpoint description.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
get:
tags:
- manage
summary: Retrieve user spend commit information
operationId: get_user_spend_commit_info
parameters:
- name: organization_id
in: query
description: Base64 encoded organization ID to filter spend commit information for a specific organization
required: true
schema:
type: string
responses:
'200':
description: User spend commit information retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/SpendCommitInfoResponse'
example:
commits:
- commit_spend_balance:
currency_code: USD
amount: 7500
commit_amount:
currency_code: USD
amount: 10000
commit_start_date: '2025-01-01'
commit_end_date: '2025-12-31T23:59:59.0000000+00:00'
'401':
description: Not authorized
'403':
description: Not authorized
security:
- BearerAuth: [ ]
x-openapi-router-controller: external_api.generated.openapi.controllers.manage_controller
get:
tags:
- manage
summary: Retrieve user spend commit information
operationId: get_user_spend_commit_info
parameters:
- name: organization_id
in: query
description: Base64 encoded organization ID to filter spend commit information for a specific organization
required: true
schema:
type: string
responses:
'200':
description: User spend commit information retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/SpendCommitInfoResponse'
example:
commits:
- commit_spend_balance:
currency_code: USD
amount: 7500
commit_amount:
currency_code: USD
amount: 10000
commit_start_date: '2025-01-01T00:00:00Z'
commit_end_date: '2025-12-31T23:59:59.0000000+00:00'
'401':
description: Not authorized
'403':
description: Not authorized
security:
- BearerAuth: [ ]
x-openapi-router-controller: external_api.generated.openapi.controllers.manage_controller
🤖 Prompt for AI Agents
In src/libs/Ideogram/openapi.yaml around lines 434 to 469, the example for spend
commit uses inconsistent date formats (commit_start_date is date-only while the
schema expects date-time); update the example so commit_start_date is a full
date-time string with timezone (e.g. ISO 8601 with time and offset) to match the
schema, and add a short timezone note to the endpoint summary/description
indicating that all dates are ISO 8601 date-time strings with timezone (UTC or
offset) so consumers know the expected format.

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.

2 participants