OpenAI account lifecycle, authenticated model catalogs, rate limits and credential envelopes.

Part of the [FlexHarness toolbox](https://code.foss.global/modelprofile.com/flexharness).
Install the components your project uses. Provider adapters are registered explicitly;
the agent and harness do not install or register vendor SDKs.

```sh
pnpm add @modelprofile.com/flexharness-providers
```

See the [toolbox usage and migration guide](https://code.foss.global/modelprofile.com/flexharness#readme)
for composition examples and the SmartAI/SmartAgent migration map.

## Authority-managed access

`OpenAiProviderAdapter.listModels()` and `getAccountRateLimits()` accept an
`IOpenAiChatGptAccessCredential` resolved by a separate account authority:

```typescript
import {
  OpenAiProviderAdapter,
  type IOpenAiChatGptAccessCredential,
} from '@modelprofile.com/flexharness-providers/accounts';

async function readAccount(grant: {
  accessToken: string;
  accountId: string;
  isFedrampAccount: boolean;
}) {
  const adapter = new OpenAiProviderAdapter();
  const access: IOpenAiChatGptAccessCredential = {
    kind: 'chatgptAccess',
    providerId: 'openai',
    accessToken: grant.accessToken,
    accountId: grant.accountId,
    isFedrampAccount: grant.isFedrampAccount,
  };
  try {
    return {
      models: await adapter.listModels(access),
      usage: await adapter.getAccountRateLimits(access),
    };
  } finally {
    await adapter.dispose();
  }
}
```

The authority verifies the account ID and FedRAMP flag against the current token,
owns refresh, and supplies a fresh access grant before each operation. A rejected
token returns `CREDENTIAL_REFRESH_REQUIRED` to the caller; the adapter does not
refresh it. Access-only grants cannot be serialized as provider credential
envelopes. Login, refresh and logout still require the full OAuth credential.

For inference, `createOpenAiChatGptModelConnection()` from `/auth` accepts
`{ accessToken, accountId, isFedrampAccount }` without a refresh token.

`refreshCredential()` failures report `requestOutcome: 'notSent'` only when the
call was rejected before a fetch invocation. All failures after a fetch invocation,
including HTTP 429, timeout, and a malformed successful response, report
`outcomeUnknown`: the provider might have rotated the refresh token. A failure
may also contain a numeric `responseStatus` and a bounded `retryAfterMs` from an
observed HTTP response. These are scheduling facts, not permission to replay
the old refresh token. Provider response bodies are never returned in this API.

## Issue Reporting and Security

Report issues and security concerns through [community.foss.global](https://community.foss.global).

## License and Legal Information

This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the repository license file.

**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.

### Trademarks

This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.

Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.

### Company Information

Task Venture Capital GmbH<br>
Registered at District Court Bremen HRB 35230 HB, Germany

For any legal inquiries or further information, please contact us via email at hello@task.vc.

By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
