Skip to content

Go: implement Balance in OpenAI driver (admin-key path) - #14876

Closed
hunnyboy1217 wants to merge 1 commit into
infiniflow:mainfrom
hunnyboy1217:feat/go-openai-balance-admin-key
Closed

hunnyboy1217 wants to merge 1 commit into
infiniflow:mainfrom
hunnyboy1217:feat/go-openai-balance-admin-key

Conversation

@hunnyboy1217

@hunnyboy1217 hunnyboy1217 commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Closes #14874.

OpenAIModel.Balance() in internal/entity/models/openai.go currently returns nil, fmt.Errorf("no such method"), so the balance command introduced in #14262 always fails against an OpenAI deployment even though it works for DeepSeek (#14632), SiliconFlow (#14643), and Moonshot.

This PR replaces the stub with a real implementation against OpenAI's supported Organization Usage & Costs API:

  • GET https://api.openai.com/v1/organization/costs?start_time=<month-start-unix>&limit=31
  • Authenticated with Authorization: Bearer <admin-api-key> (sk-admin-...).

The legacy /v1/dashboard/billing/subscription and /v1/dashboard/billing/credit_grants endpoints are intentionally not used — they are deprecated, undocumented, and reject standard project API keys with 401. /v1/organization/* is the supported replacement and only accepts admin keys, so the driver fails fast with a clear error ("openai: admin api key (sk-admin-...) required for balance") when a project key is supplied, rather than producing a confusing upstream 401.

The return shape matches the existing {balance, currency} contract used by DeepSeek (deepseek.go:569) and SiliconFlow (siliconflow.go:608) so the CLI from #14262 can render it without provider-specific code. balance is the month-to-date spend (sum of amount.value across the bucketed response) and currency is uppercased from the first non-empty bucket (typically USD).

Scope:

  • internal/entity/models/openai.go — implements Balance mirroring the DeepSeek/SiliconFlow pattern; uses the existing nonStreamCallTimeout and baseURLForRegion helpers; adds a small openaiCostsResponse type for the slim subset of the response we need.
  • conf/models/openai.json — adds "balance": "organization/costs" to url_suffix, joined to the existing https://api.openai.com/v1 base URL.

Out of scope: no interface change, no DDL, no frontend change, no changes to chat/embedding/rerank paths. APIConfig is unchanged — the existing ApiKey field is reused and required to be an admin key for this command (documented via the error message).

Type of change

  • New Feature (non-breaking change which adds functionality)

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 13, 2026
@coderabbitai

coderabbitai Bot commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a url_suffix.balance entry and implements OpenAIModel.Balance to call OpenAI’s organization costs endpoint, parse bucketed month-to-date costs, sum amounts, normalize currency (default USD), and return {spend, currency}.

Changes

OpenAI Balance API

Layer / File(s) Summary
Configuration and response contract
conf/models/openai.json, internal/entity/models/openai.go
Added url_suffix.balance mapping and a new internal struct to unmarshal OpenAI's bucketed organization costs payload (per-result amount.value and amount.currency).
Balance method implementation
internal/entity/models/openai.go
Replaced the Balance stub with an implementation that requires an admin API key, resolves a regional base URL, builds a month-start start_time query with limit=31, performs a timed GET to URLSuffix.Balance, requires HTTP 200, unmarshals openaiCostsResponse, sums amount.value across buckets, derives/uppercases currency (default USD), and returns map[string]interface{}{\"spend\": total, \"currency\": currency}.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant OpenAIModel as OpenAIModel.Balance
  participant HTTPClient
  participant OpenAIAPI as OpenAI Organization Costs API
  Caller->>OpenAIModel: Balance(apiConfig)
  OpenAIModel->>OpenAIModel: validate apiConfig.ApiKey (sk-admin-...)
  OpenAIModel->>HTTPClient: GET {baseURL}/v1/organization/costs?start_time=<month_start>&limit=31
  HTTPClient->>OpenAIAPI: HTTP GET with Authorization: Bearer <admin-key>
  OpenAIAPI-->>HTTPClient: 200 {data:[{results:[{amount:{value,currency}}...]}...]}
  HTTPClient-->>OpenAIModel: response body
  OpenAIModel->>OpenAIModel: unmarshal, sum amount.value, select currency
  OpenAIModel-->>Caller: {spend, currency}
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • infiniflow/ragflow#14632: Adds url_suffix.balance and implements a provider Balance() with similar authenticated balance-fetching logic.
  • infiniflow/ragflow#14643: Replaced a Balance stub with an HTTP-based balance/costs implementation for another provider.
  • infiniflow/ragflow#14262: CLI/admin balance command that invokes model driver Balance() implementations.

Suggested labels

ci, size:XL

Suggested reviewers

  • Haruko386

Poem

🐰 I hopped through configs, endpoints new,
I fetched the costs the admin key knew,
I summed the buckets, counted day by day,
I uppercased currency and cleared the way,
Now the CLI sings the spend array.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: implementing the Balance method in the OpenAI driver with admin-key authentication.
Description check ✅ Passed The description comprehensively covers the problem, solution, scope, and implementation details, matching the repository template with proper Type of change selection.
Linked Issues check ✅ Passed The implementation fully satisfies issue #14874 requirements: replaces stub with real OpenAI Organization Costs API call, enforces admin-key validation, returns {balance, currency} map, and includes upstream error details.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the Balance method implementation and configuration: modifications to openai.go and openai.json only, no interface changes, DDL, or unrelated functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


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.

@hunnyboy1217

Copy link
Copy Markdown
Contributor Author

Hi, @JinHai-CN ,
Could you please review my PR?

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @hunnyboy1217, Balance should be used to obtain the remaining amount, not to obtain how much amount has been used.

Let me know if I was wrong: OpenAI organization costs API

hunnyboy1217 added a commit to hunnyboy1217/ragflow that referenced this pull request May 13, 2026
Address review on infiniflow#14876: Balance should report the remaining
amount the account can spend, not the amount already consumed.

The previous revision called GET /v1/organization/costs and summed
month-to-date spend, which is the consumed amount. This commit
switches to GET /v1/dashboard/billing/credit_grants and returns
`total_available` (granted + prepaid - used) — the same semantic the
DeepSeek and SiliconFlow drivers expose through their /user/balance
endpoints.

Side effects:
- The admin-key (sk-admin-...) requirement is dropped; the credit
  grants endpoint accepts the same standard API key already wired
  through APIConfig.ApiKey for chat/embedding calls, so callers no
  longer need a separate admin key for `balance`.
- The currency is now hardcoded to "USD". The credit grants endpoint
  does not return a currency field, and OpenAI bills exclusively in
  USD.
- conf/models/openai.json url_suffix.balance switched from
  "organization/costs" to "dashboard/billing/credit_grants".
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels May 13, 2026
@hunnyboy1217

Copy link
Copy Markdown
Contributor Author

Thanks for catching this @Haruko386 — you're right, I had the semantic backwards. Just pushed f0c4aa4.

The driver now calls GET /v1/dashboard/billing/credit_grants and returns total_available (granted + prepaid − used), which lines up with how DeepSeek and SiliconFlow report balance from their /user/balance endpoints. The previous /v1/organization/costs path was summing month-to-date spend, which as you said is the consumed side, not what Balance should be returning.

A couple of things that fell out of the switch:

  • The sk-admin-... requirement is gone. dashboard/billing/credit_grants works with the regular API key that's already on APIConfig.ApiKey, so there's no separate admin key to wire up anymore.
  • Currency is hardcoded to "USD" now — the credit grants endpoint doesn't return a currency field, and OpenAI bills in USD anyway.
  • conf/models/openai.json url_suffix.balance is "dashboard/billing/credit_grants" instead of "organization/costs".

One thing worth flagging: dashboard/billing/* is a legacy surface, so a pure PAYG account with no credit grants will probably see total_available come back as 0. That still matches "remaining" (just zero remaining) and matches what those users see on the OpenAI dashboard. Happy to add a fallback if you'd rather it try something else when the response is empty — let me know what you'd prefer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/entity/models/openai.go`:
- Around line 577-657: The Balance method currently calls the unsupported
/v1/dashboard/billing/credit_grants and must be replaced to call the official
/v1/organization/costs endpoint using an admin API key; update
OpenAIModel.Balance to (1) validate apiConfig.ApiKey has the admin prefix
(sk-admin-) and return an error if not, (2) build the URL using
z.baseURLForRegion(region) and z.URLSuffix.Balance (or replace that suffix with
the organization costs path), (3) perform the GET with z.httpClient and the same
timeout/headers, (4) parse the organization costs response shape (replace
openaiCreditGrantsResponse usage) to compute remaining credit or report
balance/currency in the existing map contract, and (5) keep existing error
handling for non-200 responses and JSON unmarshal failures but adjust messages
to reference the organization costs endpoint and admin key requirement.
🪄 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: 31c26e47-b5eb-41c4-8d2e-2b3cbc4b2b6b

📥 Commits

Reviewing files that changed from the base of the PR and between 249e6a4 and f0c4aa4.

📒 Files selected for processing (2)
  • conf/models/openai.json
  • internal/entity/models/openai.go
✅ Files skipped from review due to trivial changes (1)
  • conf/models/openai.json

Comment thread internal/entity/models/openai.go Resolved
@hunnyboy1217

Copy link
Copy Markdown
Contributor Author

Hi, @Haruko386 , quick heads-up before I push again.

CodeRabbit flagged my switch to dashboard/billing/credit_grants — turns out that endpoint isn't a public API, it only works with a browser session cookie, so it'll 401 for most users. It wants me to go back to /v1/organization/costs (admin key), which is what I had originally.

The honest situation: OpenAI doesn't expose remaining balance anywhere public. That number only lives in the dashboard. /v1/organization/costs is the only documented billing endpoint and it returns spend — the consumed side, which is what you pushed back on. DeepSeek and SiliconFlow only return "remaining" because their APIs hand it over directly; OpenAI just doesn't.

Two reasonable options:

  1. Go back to /v1/organization/costs and document that for OpenAI balance means "spent this period". Ships something useful today.
  2. Close this PR until OpenAI ships a real remaining-balance endpoint.

I'd lean toward (1), but happy to go either way — which do you prefer?

@hunnyboy1217
hunnyboy1217 requested a review from Haruko386 May 13, 2026 13:39

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @hunnyboy1217, I have review your code and, based on my test:

RAGFlow(user)> create provider 'openai' instance 'test2' key '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'
SUCCESS
RAGFlow(user)> show balance from 'openai' 'test2'
CLI error: OpenAI balance API error: 403 Forbidden, body: {"error":"Your request to GET /v1/dashboard/billing/credit_grants must be made with a session key (that is, it can only be made from the browser). You made it with the following key type: secret."}

As I know, OpenAI already deprecated the legacy /dashboard/billing/credit_grants path for normal API usage. So I think the driver should not keep implementing the undocumented / browser-only credit_grants flow anymore.

hunnyboy1217 added a commit to hunnyboy1217/ragflow that referenced this pull request May 14, 2026
Address review on infiniflow#14876:

  * coderabbitai (automated review) flagged that
    /v1/dashboard/billing/credit_grants is not a documented or
    supported API endpoint and recommended returning to the official
    /v1/organization/costs surface with admin-key validation.

  * Haruko386 reproduced the failure: requests to
    /v1/dashboard/billing/credit_grants are rejected with 403 and
    the message "must be made with a session key", confirming the
    legacy path is browser-session-only and unusable for API callers.

This commit reverts f0c4aa4 (the credit_grants attempt) and
restores the GET /v1/organization/costs implementation gated on an
admin API key (sk-admin-...).

Acknowledge the unresolved semantic raised by Haruko386: peer drivers
expose Balance as remaining credit, but OpenAI does not publish a
remaining-balance API. The doc comment on Balance() is expanded to
state explicitly that this driver returns month-to-date spend (the
only documented metric available), and to point at the next step:
swap to a remaining-balance endpoint when OpenAI ships one.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels May 14, 2026
hunnyboy1217 added a commit to hunnyboy1217/ragflow that referenced this pull request May 14, 2026
Address review on infiniflow#14876:

  * coderabbitai (automated review) flagged that
    /v1/dashboard/billing/credit_grants is not a documented or
    supported API endpoint and recommended returning to the official
    /v1/organization/costs surface with admin-key validation.

  * Haruko386 reproduced the failure: requests to
    /v1/dashboard/billing/credit_grants are rejected with 403 and
    the message "must be made with a session key", confirming the
    legacy path is browser-session-only and unusable for API callers.

This commit reverts f0c4aa4 (the credit_grants attempt) and
restores the GET /v1/organization/costs implementation gated on an
admin API key (sk-admin-...).

Acknowledge the unresolved semantic raised by Haruko386: peer drivers
expose Balance as remaining credit, but OpenAI does not publish a
remaining-balance API. The doc comment on Balance() is expanded to
state explicitly that this driver returns month-to-date spend (the
only documented metric available), and to point at the next step:
swap to a remaining-balance endpoint when OpenAI ships one.
@hunnyboy1217
hunnyboy1217 force-pushed the feat/go-openai-balance-admin-key branch from 59904e3 to bb6db00 Compare May 14, 2026 04:35

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/entity/models/openai.go`:
- Around line 593-610: The Balance method in internal/entity/models/openai.go
must not return month-to-date spend in the shared "balance" field; change
Balance to either (A) stop populating the shared balance shape and instead
return a clear unsupported error (e.g., return nil,
ErrUnsupportedBalanceForProvider) so callers don't display spend as remaining
credit, or (B) extend the returned contract to include a provider-specific
"spend" field and populate that instead of balance; implement one of these
approaches in the Balance function (and adjust any helper functions it calls) so
OpenAI spend is never exposed under the existing `balance` semantics.
🪄 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: 52275aa7-badd-4a4b-851e-efd3e4d2e42b

📥 Commits

Reviewing files that changed from the base of the PR and between f0c4aa4 and bb6db00.

📒 Files selected for processing (2)
  • conf/models/openai.json
  • internal/entity/models/openai.go
✅ Files skipped from review due to trivial changes (1)
  • conf/models/openai.json

Comment thread internal/entity/models/openai.go Resolved
hunnyboy1217 added a commit to hunnyboy1217/ragflow that referenced this pull request May 14, 2026
Address review on infiniflow#14876 (Haruko386): peer drivers' Balance() returns
the *remaining* spendable amount, but the OpenAI driver returns
*already-spent* costs because OpenAI exposes no remaining-balance API
to API callers. The previous comment did not flag this clearly.

Expand the Balance() doc comment to:
  * state the spend-vs-remaining inversion explicitly
  * record why /v1/dashboard/billing/credit_grants is not used
    (browser-session-only, returns 403 to API keys), so future
    contributors do not re-attempt that path
  * leave a forward pointer: switch to a remaining-balance endpoint
    when OpenAI ships one

No code change beyond the comment; the implementation remains the
admin-key /v1/organization/costs path from 249e6a4.
@hunnyboy1217
hunnyboy1217 force-pushed the feat/go-openai-balance-admin-key branch 2 times, most recently from 645e47b to 113c57b Compare May 14, 2026 04:45
Replace the "no such method" stub in OpenAIModel.Balance with a real
implementation against the Organization Costs endpoint
(GET /v1/organization/costs), authenticated by an admin API key
(sk-admin-...). The legacy /v1/dashboard/billing/* endpoints are
intentionally not used: the documented /organization/* surface
requires admin keys, and the legacy /dashboard/billing/credit_grants
path is browser-session-only and rejects API keys with 403
(reproduced in review by Haruko386).

Return shape: {spend, currency} — deliberately diverges from the
{balance, currency} shape used by the DeepSeek (infiniflow#14632) and
SiliconFlow (infiniflow#14643) drivers. OpenAI exposes no remaining-balance
API to API callers, so labeling month-to-date spend as "balance"
would conflate opposite quantities (remaining vs consumed) under one
field name and silently mislead users. Raised in review on infiniflow#14876
by coderabbitai; the doc comment on Balance() records the rationale
and a forward path: emit "balance" alongside or instead of "spend"
once OpenAI ships a documented remaining-balance endpoint.

Fixes infiniflow#14874
@hunnyboy1217
hunnyboy1217 force-pushed the feat/go-openai-balance-admin-key branch from 113c57b to 83130bd Compare May 14, 2026 04:56
@hunnyboy1217

Copy link
Copy Markdown
Contributor Author

Hi, @Haruko386 ,
Could you please review my PR again?

@hunnyboy1217
hunnyboy1217 requested review from Haruko386 May 14, 2026 04:58

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
internal/entity/models/openai.go (1)

597-607: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Keep the shared balance contract here.

Balance() is still wired into the provider-agnostic balance flow, so switching the payload to {"spend": ...} breaks the contract this PR is supposed to preserve and will misalign the CLI/output path that expects "balance". If you want to expose spend separately, that higher-level contract needs to change in the same PR; otherwise keep returning the established "balance" key here.

Minimal contract-preserving fix
-// Return shape: {spend, currency}. Note this deliberately diverges
-// from the {balance, currency} shape used by the DeepSeek and
-// SiliconFlow drivers, because OpenAI does not expose a remaining-
-// balance endpoint to API callers and we refuse to label spend as
-// "balance" — those are opposite quantities and conflating them
-// silently misleads users (raised in review on `#14876` by
-// coderabbitai). The legacy /v1/dashboard/billing/credit_grants path
-// is browser-session-only and rejects API keys with 403; the
-// /v1/organization/* surface only exposes costs (consumption). When
-// OpenAI ships a documented remaining-balance endpoint, switch to it
-// and emit "balance" alongside (or instead of) "spend".
+// Return shape: {balance, currency}. This preserves the shared driver
+// contract used by the balance command until callers are widened to
+// represent spend separately.

 	return map[string]interface{}{
-		"spend":    total,
+		"balance":  total,
 		"currency": currency,
 	}, nil

Also applies to: 690-693

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/entity/models/openai.go` around lines 597 - 607, The Balance()
implementation in internal/entity/models/openai.go must preserve the shared
"balance" contract instead of returning a {"spend": ...} payload; update the
code paths in the Balance() function (and the related return at the other spot
around the 690-693 region) to emit a JSON/object with key "balance" (and keep
currency) so the provider-agnostic flow and CLI continue to receive "balance",
while any internal or new "spend" value can be added separately if needed behind
a contract change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@internal/entity/models/openai.go`:
- Around line 597-607: The Balance() implementation in
internal/entity/models/openai.go must preserve the shared "balance" contract
instead of returning a {"spend": ...} payload; update the code paths in the
Balance() function (and the related return at the other spot around the 690-693
region) to emit a JSON/object with key "balance" (and keep currency) so the
provider-agnostic flow and CLI continue to receive "balance", while any internal
or new "spend" value can be added separately if needed behind a contract change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a27f6197-7cdd-47dc-8cc8-182a832276cf

📥 Commits

Reviewing files that changed from the base of the PR and between 113c57b and 83130bd.

📒 Files selected for processing (2)
  • conf/models/openai.json
  • internal/entity/models/openai.go
✅ Files skipped from review due to trivial changes (1)
  • conf/models/openai.json

@Haruko386 Haruko386 added the invalid This doesn't seem right label May 18, 2026
@hunnyboy1217

Copy link
Copy Markdown
Contributor Author

Hi @Haruko386, thanks for testing this and for the push-back — you're right that Balance should mean "remaining", and I went down a rabbit hole trying to make OpenAI give me that number.

Here's where I've landed after trying every endpoint:

  • dashboard/billing/credit_grants is the only thing that ever returned a "remaining" figure, but as your test showed it's browser-session-only and 403s any real API key. So it's a dead end for us.
  • organization/costs works with an admin key, but it only reports spend (what's been used), not what's left.

The honest situation is that OpenAI just doesn't expose remaining balance through any public API — that number only lives in their dashboard. DeepSeek and SiliconFlow can return "remaining" because their APIs hand it over directly; OpenAI doesn't have an equivalent.

So I think it comes down to two options, and I'd rather you decide than keep guessing:

  1. Ship organization/costs (admin key) but be upfront that for OpenAI, balance shows month-to-date spend, documented clearly so nobody mistakes it for remaining credit.
  2. Leave OpenAI's Balance unimplemented for now (returns a clear "not supported" error) until OpenAI ships a real remaining-balance endpoint.

I'm happy to go either way — just let me know which you'd prefer and I'll update the PR.

@Haruko386

Copy link
Copy Markdown
Member

@hunnyboy1217 Just leave it unimplemented is OK

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

Labels

invalid This doesn't seem right size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Go - implement Balance in OpenAI driver (admin-key path)

3 participants