# Create provider in project

`POST /v1/projects/{project}/providers`, operation `providers.CreateProviderInProject`

Adds a provider: an API key for a model provider. Its service must accept the key first.

A project's own provider serves the project's own models alone, and is shared with no other project. Adding one fails with failed_precondition where a policy enforces llmgateway.projectProvidersDisabled.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `project` | path | Yes | `string` | The project's ID. |
| `validateOnly` | query | No | `boolean` | Checks the provider, with its service too, without adding it. |

## Request body

Content-Type: `application/json` (required)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `apiKey` | `string` | No | The API key, required for API_KEY types and refused for WORKLOAD_IDENTITY types. Its service must accept it first. Responses never include it. |
| `availability` | `Availability` | No | The projects the provider is shared with. None, unless set. Setting it also takes llmgateway.providers.setAvailability. Only an organization's provider is shared. |
| `availability.allProjects` | `boolean` | Yes | Every project, including those created later. |
| `availability.projects` | `string[]` | Yes | Projects, projects/{project_id}, when not all of them; at most 500. Past that, make the resource available to every project. |
| `config` | `map<string, string>` | No | Settings, as the type's configFields describe them: keys of lowercase letters, digits and underscores, values of at most 2048 characters. Empty when adding a WORKLOAD_IDENTITY provider, which is configured once its cloud trusts it. |
| `displayName` | `string` | No | Name shown in user interfaces. Defaults to the type's name. |
| `type` | `string` | Yes | The provider's type, such as providerTypes/openai. |

## Responses

### 201

Created

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `availability` | `Availability` | Yes | For an organization's provider: the projects it is shared with, which may make models of their own through it; a project's own model whose provider isn't shared with it serves nothing. The organization's models, and what projects adopted of them, serve wherever the models are shared, whomever the provider is shared with. A project's own provider is shared with none. |
| `availability.allProjects` | `boolean` | Yes | Every project, including those created later. |
| `availability.projects` | `string[]` | Yes | Projects, projects/{project_id}, when not all of them; at most 500. Past that, make the resource available to every project. |
| `config` | `map<string, string>` | Yes | Settings, as the type's configFields describe them. |
| `createTime` | `string (date-time)` | No | When the provider was added; unset on one that was only validated. |
| `displayName` | `string` | Yes | Name shown in user interfaces. Defaults to the type's name. |
| `keyHint` | `string` | Yes | The last characters of the API key, to recognize it by; empty for providers connected by WORKLOAD_IDENTITY. |
| `name` | `string` | Yes | Resource name, organizations/{organization_id}/providers/{provider_id}, or projects/{project_id}/providers/{provider_id} for a project's own. |
| `state` | `string` | Yes | Whether the provider's service accepts the credential: ACTIVE, it accepted it when it was last verified; NEEDS_ATTENTION, it refused the credential or settings, or the provider isn't set up yet, and stateReason says why. Values: `ACTIVE`, `NEEDS_ATTENTION`. |
| `stateReason` | `string` | Yes | Why the provider needs attention. |
| `trust` | `ProviderTrust` | No | What the cloud trusts of kosem for this provider, for a type connected by WORKLOAD_IDENTITY. |
| `trust.attributeCondition` | `string` | No | For Google Cloud: the attribute condition that the workload identity provider must have, which takes the identity tokens of this organization's providers, its projects' own among them, and of no environment. kosem's issuer is every customer's, so a provider without it trusts them all; each service account then lets one provider's subject act as it. |
| `trust.issuer` | `string` | Yes | kosem's issuer of identity tokens, whose keys it publishes at /.well-known/jwks.json. |
| `trust.subject` | `string` | Yes | The subject of kosem's identity tokens for the provider: provider:{name}. Only kosem mints it, so trusting it trusts no other organization's provider and no environment. |
| `type` | `string` | Yes | The provider's type, such as providerTypes/openai. It never changes. |
| `updateTime` | `string (date-time)` | No | When the provider was last updated; unset on one that was only validated. |
| `verifyTime` | `string (date-time)` | Yes | When the provider's service last accepted or refused the credential. |

### default

Error

Base URL: `https://api.kosem.ai`. See [API conventions](https://docs.kosem.ai/reference/api-conventions.md) for authentication, pagination and errors, and [https://docs.kosem.ai/openapi.yaml](https://docs.kosem.ai/openapi.yaml) for the full OpenAPI document.