> ## Documentation Index
> Fetch the complete documentation index at: https://gaia-docs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Credential

> Creates a new credential for AI providers. For Ollama, it manages models within a single credential.

## Body Parameters

<ParamField body="name" type="string">
  Credential name or model name for Ollama
</ParamField>

<ParamField body="provider" type="string" required>
  Provider name (e.g., openai, anthropic, ollama)
</ParamField>

<ParamField body="apiKey" type="string" required>
  API key for the provider
</ParamField>

<ParamField body="credentialType" type="string" required>
  Type of credential
</ParamField>

<ParamField body="baseUrl" type="string | null">
  Optional base URL for the provider
</ParamField>

<ParamField body="dynamicFields" type="object">
  Additional dynamic fields
</ParamField>

<ParamField body="proxy" type="boolean">
  Whether to use proxy
</ParamField>

<ParamField body="isValid" type="boolean">
  Validation status
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Indicates if the credential was created successfully
</ResponseField>

<ResponseField name="message" type="string">
  Success or error message
</ResponseField>

<ResponseField name="credentialId" type="string">
  The ID of the newly created credential
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url http://localhost:3000/api/v1/credentials \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "name": "OpenAI Production",
      "provider": "openai",
      "apiKey": "sk-...",
      "credentialType": "api_key",
      "baseUrl": null,
      "proxy": false,
      "isValid": true
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('http://localhost:3000/api/v1/credentials', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <token>',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: "OpenAI Production",
      provider: "openai",
      apiKey: "sk-...",
      credentialType: "api_key",
      baseUrl: null,
      proxy: false,
      isValid: true
    })
  });

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  url = "http://localhost:3000/api/v1/credentials"
  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
  }
  payload = {
      "name": "OpenAI Production",
      "provider": "openai",
      "apiKey": "sk-...",
      "credentialType": "api_key",
      "baseUrl": None,
      "proxy": False,
      "isValid": True
  }

  response = requests.post(url, headers=headers, json=payload)
  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - Success theme={null}
  {
    "success": true,
    "message": "Credential created successfully",
    "credentialId": "cred_123abc"
  }
  ```

  ```json 400 - Bad Request theme={null}
  {
    "success": false,
    "message": "Valid credential for provider already exists"
  }
  ```

  ```json 401 - Unauthorized theme={null}
  {
    "success": false,
    "message": "Unauthorized"
  }
  ```
</ResponseExample>

## Notes

* For **Ollama** provider, credentials manage models within a single credential
* The `name` field can represent the credential name or model name for Ollama
* Ensure the API key is valid before creating the credential
* The system checks for existing valid credentials for the same provider
