# Agent: Providers

**Page:** api/agent/providers

[Download Raw Markdown](./api/agent/providers.md)

---

{/* AUTO-GENERATED — Do not edit manually. Regenerate with: npm run docs:api:generate */}



## Agent: Providers

List available LLM providers, retrieve supported authentication methods, and complete OAuth authorization flows for connecting providers to a workspace.

### `GET /api/v1/workspaces/{workspaceID}/providers`

Get a list of all available AI providers, including both available and connected ones. Returns the full provider catalog, the default model mapping, and which providers are currently connected in the workspace.

#### Parameters

| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| `workspaceID` | path | string | Yes | Workspace identifier |

#### Response



```json
{
  "all": [
    {
      "name": "Anthropic",
      "env": ["ANTHROPIC_API_KEY"],
      "id": "anthropic",
      "npm": "@ai-sdk/anthropic",
      "api": "https://api.anthropic.com",
      "models": {}
    },
    {
      "name": "OpenAI",
      "env": ["OPENAI_API_KEY"],
      "id": "openai",
      "npm": "@ai-sdk/openai",
      "api": "https://api.openai.com/v1",
      "models": {}
    }
  ],
  "default": {
    "anthropic": "claude-sonnet-4-20250514",
    "openai": "gpt-4o"
  },
  "connected": ["anthropic"]
}
```



#### SDK usage

```ts
const providers = await client.agent.providers.list({
  workspaceID: "ws_01HXYZABCDEF"
});
```

---

### `GET /api/v1/workspaces/{workspaceID}/providers/auth`

Retrieve the available authentication methods for all AI providers. Returns a map keyed by provider ID, where each value is an array of supported auth methods (OAuth, API key, etc.).

#### Parameters

| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| `workspaceID` | path | string | Yes | Workspace identifier |

#### Response



```json
{
  "anthropic": [
    { "type": "api", "label": "API Key" }
  ],
  "openai": [
    { "type": "api", "label": "API Key" }
  ],
  "google": [
    { "type": "oauth", "label": "Google OAuth" },
    { "type": "api", "label": "API Key" }
  ]
}
```



#### SDK usage

```ts
const methods = await client.agent.providers.getAuthMethods({
  workspaceID: "ws_01HXYZABCDEF"
});
```

---

### `POST /api/v1/workspaces/{workspaceID}/providers/{providerID}/oauth/authorize`

Initiate OAuth authorization for a specific AI provider. Returns the authorization URL the user should be redirected to, the method used (`auto` or `code`), and any user-facing instructions.

#### Parameters

| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| `providerID` | path | string | Yes | Provider ID |
| `workspaceID` | path | string | Yes | Workspace identifier |

#### Request Body

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `method` | number | Yes | Auth method index |

```json
{
  "method": 0
}
```

#### Response



```json
{
  "url": "https://accounts.google.com/o/oauth2/v2/auth?client_id=1234567890&redirect_uri=https%3A%2F%2Fhoody.com%2Fcallback&scope=openid+email+profile&response_type=code",
  "method": "auto",
  "instructions": "Visit the URL to grant access. You will be redirected back automatically."
}
```



```json
{
  "data": null,
  "errors": [
    {
      "field": "method",
      "message": "Auth method index is out of range"
    }
  ],
  "success": false
}
```



#### SDK usage

```ts
const auth = await client.agent.providers.authorizeOAuth({
  workspaceID: "ws_01HXYZABCDEF",
  providerID: "google",
  data: {
    method: 0
  }
});
```

---

### `POST /api/v1/workspaces/{workspaceID}/providers/{providerID}/oauth/callback`

Handle the OAuth callback from a provider after the user completes authorization. Exchanges the authorization code for an access token and connects the provider to the workspace.

#### Parameters

| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| `providerID` | path | string | Yes | Provider ID |
| `workspaceID` | path | string | Yes | Workspace identifier |

#### Request Body

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `method` | number | Yes | Auth method index |
| `code` | string | No | OAuth authorization code |

```json
{
  "method": 0,
  "code": "4/0AQlEd8xCjYYSAMPLE_CODE_HERE"
}
```

#### Response



```json
true
```



```json
{
  "data": null,
  "errors": [
    {
      "field": "code",
      "message": "Invalid or expired authorization code"
    }
  ],
  "success": false
}
```



#### SDK usage

```ts
const connected = await client.agent.providers.callbackOAuth({
  workspaceID: "ws_01HXYZABCDEF",
  providerID: "google",
  data: {
    method: 0,
    code: "4/0AQlEd8xCjYYSAMPLE_CODE_HERE"
  }
});
```