Skip to content

feat:Add /v2/hardware API endpoint to DeepInfra OpenAPI spec#257

Merged
HavenDV merged 1 commit intomainfrom
bot/update-openapi_202603120105
Mar 12, 2026
Merged

feat:Add /v2/hardware API endpoint to DeepInfra OpenAPI spec#257
HavenDV merged 1 commit intomainfrom
bot/update-openapi_202603120105

Conversation

@HavenDV
Copy link
Contributor

@HavenDV HavenDV commented Mar 12, 2026

Summary by CodeRabbit

  • New Features
    • Launched the new /v2/hardware API endpoint, enabling users to query and discover available hardware options with detailed pricing information. Supports both serverless hardware with per-token billing (separate input and output token costs) and dedicated hardware with per-minute billing. API key authentication and model query parameter are required for endpoint access.

@HavenDV HavenDV enabled auto-merge (squash) March 12, 2026 01:06
@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2026

Walkthrough

This pull request introduces a new /v2/hardware API endpoint to the DeepInfra OpenAPI specification that returns hardware configuration options based on a model parameter. Four new schemas define hardware options, pricing structures for serverless and dedicated deployments, and the response structure.

Changes

Cohort / File(s) Summary
OpenAPI Hardware Endpoint Addition
src/libs/DeepInfra/openapi.yaml
Added /v2/hardware GET endpoint with model query parameter and xi-api-key header support. Introduced HardwareOption schema with id, name, type (serverless/dedicated), and pricing properties. Added HardwarePricingServerless (token-based pricing) and HardwarePricingDedicated (minute-based pricing) schemas, along with HardwareResponse wrapper schema.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A new hardware endpoint springs to life,
With schemas dancing, free of strife,
Serverless and dedicated, priced just right,
The API whispers through the digital night!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 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 changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title Check ✅ Passed Title check skipped as CodeRabbit has written the PR title.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bot/update-openapi_202603120105

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.

@HavenDV HavenDV merged commit 01dde0e into main Mar 12, 2026
3 of 4 checks passed
@HavenDV HavenDV deleted the bot/update-openapi_202603120105 branch March 12, 2026 01:07
@coderabbitai coderabbitai bot changed the title feat:@coderabbitai feat:Add /v2/hardware API endpoint to DeepInfra OpenAPI spec Mar 12, 2026
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/libs/DeepInfra/openapi.yaml`:
- Around line 6717-6742: The HardwareOption schema uses pricing:anyOf which
allows ambiguous mixed payloads; update the upstream OpenAPI source (not the
checked-in YAML) so HardwareOption uses pricing:oneOf with a discriminator keyed
on the existing type property (propertyName: "type") and mapping "serverless" ->
"#/components/schemas/HardwarePricingServerless" and "dedicated" ->
"#/components/schemas/HardwarePricingDedicated" so the type field
deterministically selects the pricing schema (this will eliminate the
AnyOfJsonConverter<T1,T2> ambiguity and regenerate correct discriminated union
code).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ae43bbe2-097e-4c5e-bb90-caf5ca9a2696

📥 Commits

Reviewing files that changed from the base of the PR and between b974bdf and 3fac33b.

⛔ Files ignored due to path filters (17)
  • src/libs/DeepInfra/Generated/DeepInfra..JsonSerializerContext.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.DeepInfraClient.GetHardware.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.IDeepInfraClient.GetHardware.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.JsonConverters.HardwareOptionType.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.JsonConverters.HardwareOptionTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.JsonSerializerContextTypes.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.GetHardwareV2HardwareGetXiApiKey.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.GetHardwareV2HardwareGetXiApiKey.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.HardwareOption.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.HardwareOption.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.HardwareOptionType.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.HardwarePricingDedicated.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.HardwarePricingDedicated.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.HardwarePricingServerless.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.HardwarePricingServerless.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.HardwareResponse.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.HardwareResponse.g.cs is excluded by !**/generated/**
📒 Files selected for processing (1)
  • src/libs/DeepInfra/openapi.yaml

Comment on lines +6717 to +6742
HardwareOption:
title: HardwareOption
required:
- id
- name
- type
- pricing
type: object
properties:
id:
title: Id
type: string
name:
title: Name
type: string
type:
title: Type
enum:
- serverless
- dedicated
type: string
pricing:
title: Pricing
anyOf:
- $ref: '#/components/schemas/HardwarePricingServerless'
- $ref: '#/components/schemas/HardwarePricingDedicated'
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Make pricing a discriminated oneOf, not anyOf.

Right now the contract allows ambiguous payloads: a pricing object containing fields from both variants is valid per spec, and the generated AnyOfJsonConverter<T1, T2> in src/libs/DeepInfra/Generated/DeepInfra.JsonConverters.AnyOf2.g.cs:1-95 will just take the first branch that deserializes. That means mixed or mismatched type/pricing combinations can be accepted and interpreted arbitrarily by clients. Please model this as a discriminated union—ideally at the HardwareOption level with type selecting the matching pricing schema—in the upstream OpenAPI source.

As per coding guidelines, src/libs/DeepInfra/openapi.yaml: The OpenAPI spec is fetched from https://api.deepinfra.com/openapi.json and stored in src/libs/DeepInfra/openapi.yaml -- do not manually modify the spec file

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/libs/DeepInfra/openapi.yaml` around lines 6717 - 6742, The HardwareOption
schema uses pricing:anyOf which allows ambiguous mixed payloads; update the
upstream OpenAPI source (not the checked-in YAML) so HardwareOption uses
pricing:oneOf with a discriminator keyed on the existing type property
(propertyName: "type") and mapping "serverless" ->
"#/components/schemas/HardwarePricingServerless" and "dedicated" ->
"#/components/schemas/HardwarePricingDedicated" so the type field
deterministically selects the pricing schema (this will eliminate the
AnyOfJsonConverter<T1,T2> ambiguity and regenerate correct discriminated union
code).

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