# API Keys ## Create `client.agents.apiKeys.create(stringagentUuid, APIKeyCreateParamsbody?, RequestOptionsoptions?): APIKeyCreateResponse` **post** `/v2/gen-ai/agents/{agent_uuid}/api_keys` To create an agent API key, send a POST request to `/v2/gen-ai/agents/{agent_uuid}/api_keys`. ### Parameters - `agentUuid: string` - `body: APIKeyCreateParams` - `agent_uuid?: string` Agent id - `name?: string` A human friendly name to identify the key ### Returns - `APIKeyCreateResponse` - `api_key_info?: APIAgentAPIKeyInfo` Agent API Key Info - `created_at?: string` Creation date - `created_by?: string` Created by - `deleted_at?: string` Deleted date - `name?: string` Name - `secret_key?: string` - `uuid?: string` Uuid ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const apiKey = await client.agents.apiKeys.create('"123e4567-e89b-12d3-a456-426614174000"'); console.log(apiKey.api_key_info); ``` ## Update `client.agents.apiKeys.update(stringapiKeyUuid, APIKeyUpdateParamsparams, RequestOptionsoptions?): APIKeyUpdateResponse` **put** `/v2/gen-ai/agents/{agent_uuid}/api_keys/{api_key_uuid}` To update an agent API key, send a PUT request to `/v2/gen-ai/agents/{agent_uuid}/api_keys/{api_key_uuid}`. ### Parameters - `apiKeyUuid: string` - `params: APIKeyUpdateParams` - `body_agent_uuid?: string` Body param: Agent id - `api_key_uuid?: string` Body param: API key ID - `name?: string` Body param: Name ### Returns - `APIKeyUpdateResponse` - `api_key_info?: APIAgentAPIKeyInfo` Agent API Key Info - `created_at?: string` Creation date - `created_by?: string` Created by - `deleted_at?: string` Deleted date - `name?: string` Name - `secret_key?: string` - `uuid?: string` Uuid ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const apiKey = await client.agents.apiKeys.update('"123e4567-e89b-12d3-a456-426614174000"', { path_agent_uuid: '"123e4567-e89b-12d3-a456-426614174000"', }); console.log(apiKey.api_key_info); ``` ## List `client.agents.apiKeys.list(stringagentUuid, APIKeyListParamsquery?, RequestOptionsoptions?): APIKeyListResponse` **get** `/v2/gen-ai/agents/{agent_uuid}/api_keys` To list all agent API keys, send a GET request to `/v2/gen-ai/agents/{agent_uuid}/api_keys`. ### Parameters - `agentUuid: string` - `query: APIKeyListParams` - `page?: number` Page number. - `per_page?: number` Items per page. ### Returns - `APIKeyListResponse` - `api_key_infos?: Array` Api key infos - `created_at?: string` Creation date - `created_by?: string` Created by - `deleted_at?: string` Deleted date - `name?: string` Name - `secret_key?: string` - `uuid?: string` Uuid - `links?: APILinks` Links to other pages - `pages?: Pages` Information about how to reach other pages - `first?: string` First page - `last?: string` Last page - `next?: string` Next page - `previous?: string` Previous page - `meta?: APIMeta` Meta information about the data set - `page?: number` The current page - `pages?: number` Total number of pages - `total?: number` Total amount of items over all pages ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const apiKeys = await client.agents.apiKeys.list('"123e4567-e89b-12d3-a456-426614174000"'); console.log(apiKeys.api_key_infos); ``` ## Delete `client.agents.apiKeys.delete(stringapiKeyUuid, APIKeyDeleteParamsparams, RequestOptionsoptions?): APIKeyDeleteResponse` **delete** `/v2/gen-ai/agents/{agent_uuid}/api_keys/{api_key_uuid}` To delete an API key for an agent, send a DELETE request to `/v2/gen-ai/agents/{agent_uuid}/api_keys/{api_key_uuid}`. ### Parameters - `apiKeyUuid: string` - `params: APIKeyDeleteParams` - `agent_uuid: string` A unique identifier for your agent. ### Returns - `APIKeyDeleteResponse` - `api_key_info?: APIAgentAPIKeyInfo` Agent API Key Info - `created_at?: string` Creation date - `created_by?: string` Created by - `deleted_at?: string` Deleted date - `name?: string` Name - `secret_key?: string` - `uuid?: string` Uuid ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const apiKey = await client.agents.apiKeys.delete('"123e4567-e89b-12d3-a456-426614174000"', { agent_uuid: '"123e4567-e89b-12d3-a456-426614174000"', }); console.log(apiKey.api_key_info); ``` ## Regenerate `client.agents.apiKeys.regenerate(stringapiKeyUuid, APIKeyRegenerateParamsparams, RequestOptionsoptions?): APIKeyRegenerateResponse` **put** `/v2/gen-ai/agents/{agent_uuid}/api_keys/{api_key_uuid}/regenerate` To regenerate an agent API key, send a PUT request to `/v2/gen-ai/agents/{agent_uuid}/api_keys/{api_key_uuid}/regenerate`. ### Parameters - `apiKeyUuid: string` - `params: APIKeyRegenerateParams` - `agent_uuid: string` Agent id ### Returns - `APIKeyRegenerateResponse` - `api_key_info?: APIAgentAPIKeyInfo` Agent API Key Info - `created_at?: string` Creation date - `created_by?: string` Created by - `deleted_at?: string` Deleted date - `name?: string` Name - `secret_key?: string` - `uuid?: string` Uuid ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const response = await client.agents.apiKeys.regenerate('"123e4567-e89b-12d3-a456-426614174000"', { agent_uuid: '"123e4567-e89b-12d3-a456-426614174000"', }); console.log(response.api_key_info); ```