1. Registry
  2. Packages
  3. Mongodbatlas Provider
  4. API Docs
  5. getAiModelApiKeys
Viewing docs for MongoDB Atlas v4.15.0
published on Friday, Aug 28, 2026 by Pulumi
mongodbatlas logo mongodbatlas logo
Viewing docs for MongoDB Atlas v4.15.0
published on Friday, Aug 28, 2026 by Pulumi

    mongodbatlas.getAiModelApiKeys returns all AI Model API Keys for the specified project.

    NOTE: The secret attribute is not available through this data source as it is only returned during initial creation. To access the secret, use the resource.

    Example Usage

    S

    import * as pulumi from "@pulumi/pulumi";
    import * as mongodbatlas from "@pulumi/mongodbatlas";
    
    const thisAiModelApiKey = new mongodbatlas.AiModelApiKey("this", {
        projectId: projectId,
        name: "example-ai-model-key",
        cloud: "ANY",
        geography: "ANY",
    });
    const _this = mongodbatlas.getAiModelApiKeyOutput({
        projectId: projectId,
        apiKeyId: thisAiModelApiKey.apiKeyId,
    });
    const thisGetAiModelApiKeys = mongodbatlas.getAiModelApiKeys({
        projectId: projectId,
    });
    export const aiModelApiKeyId = thisAiModelApiKey.apiKeyId;
    export const aiModelApiKeySecret = thisAiModelApiKey.secret;
    export const aiModelApiKeyName = _this.name;
    export const aiModelApiKeyEndpoint = _this.endpoint;
    export const aiModelApiKeysResults = thisGetAiModelApiKeys.then(thisGetAiModelApiKeys => thisGetAiModelApiKeys.results);
    
    import pulumi
    import pulumi_mongodbatlas as mongodbatlas
    
    this_ai_model_api_key = mongodbatlas.AiModelApiKey("this",
        project_id=project_id,
        name="example-ai-model-key",
        cloud="ANY",
        geography="ANY")
    this = mongodbatlas.get_ai_model_api_key_output(project_id=project_id,
        api_key_id=this_ai_model_api_key.api_key_id)
    this_get_ai_model_api_keys = mongodbatlas.get_ai_model_api_keys(project_id=project_id)
    pulumi.export("aiModelApiKeyId", this_ai_model_api_key.api_key_id)
    pulumi.export("aiModelApiKeySecret", this_ai_model_api_key.secret)
    pulumi.export("aiModelApiKeyName", this.name)
    pulumi.export("aiModelApiKeyEndpoint", this.endpoint)
    pulumi.export("aiModelApiKeysResults", this_get_ai_model_api_keys.results)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-mongodbatlas/sdk/v4/go/mongodbatlas"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		thisAiModelApiKey, err := mongodbatlas.NewAiModelApiKey(ctx, "this", &mongodbatlas.AiModelApiKeyArgs{
    			ProjectId: pulumi.Any(projectId),
    			Name:      pulumi.String("example-ai-model-key"),
    			Cloud:     pulumi.String("ANY"),
    			Geography: pulumi.String("ANY"),
    		})
    		if err != nil {
    			return err
    		}
    		this := mongodbatlas.GetAiModelApiKeyOutput(ctx, mongodbatlas.GetAiModelApiKeyOutputArgs{
    			ProjectId: pulumi.Any(projectId),
    			ApiKeyId:  thisAiModelApiKey.ApiKeyId,
    		}, nil)
    		thisGetAiModelApiKeys, err := mongodbatlas.GetAiModelApiKeys(ctx, &mongodbatlas.LookupAiModelApiKeysArgs{
    			ProjectId: projectId,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("aiModelApiKeyId", thisAiModelApiKey.ApiKeyId)
    		ctx.Export("aiModelApiKeySecret", thisAiModelApiKey.Secret)
    		ctx.Export("aiModelApiKeyName", this.Name())
    		ctx.Export("aiModelApiKeyEndpoint", this.Endpoint())
    		ctx.Export("aiModelApiKeysResults", thisGetAiModelApiKeys.Results)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Mongodbatlas = Pulumi.Mongodbatlas;
    
    return await Deployment.RunAsync(() => 
    {
        var thisAiModelApiKey = new Mongodbatlas.AiModelApiKey("this", new()
        {
            ProjectId = projectId,
            Name = "example-ai-model-key",
            Cloud = "ANY",
            Geography = "ANY",
        });
    
        var @this = Mongodbatlas.GetAiModelApiKey.Invoke(new()
        {
            ProjectId = projectId,
            ApiKeyId = thisAiModelApiKey.ApiKeyId,
        });
    
        var thisGetAiModelApiKeys = Mongodbatlas.GetAiModelApiKeys.Invoke(new()
        {
            ProjectId = projectId,
        });
    
        return new Dictionary<string, object?>
        {
            ["aiModelApiKeyId"] = thisAiModelApiKey.ApiKeyId,
            ["aiModelApiKeySecret"] = thisAiModelApiKey.Secret,
            ["aiModelApiKeyName"] = @this.Apply(@this => @this.Apply(getAiModelApiKeyResult => getAiModelApiKeyResult.Name)),
            ["aiModelApiKeyEndpoint"] = @this.Apply(@this => @this.Apply(getAiModelApiKeyResult => getAiModelApiKeyResult.Endpoint)),
            ["aiModelApiKeysResults"] = thisGetAiModelApiKeys.Apply(getAiModelApiKeysResult => getAiModelApiKeysResult.Results),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.mongodbatlas.AiModelApiKey;
    import com.pulumi.mongodbatlas.AiModelApiKeyArgs;
    import com.pulumi.mongodbatlas.MongodbatlasFunctions;
    import com.pulumi.mongodbatlas.inputs.GetAiModelApiKeyArgs;
    import com.pulumi.mongodbatlas.inputs.GetAiModelApiKeysArgs;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var thisAiModelApiKey = new AiModelApiKey("thisAiModelApiKey", AiModelApiKeyArgs.builder()
                .projectId(projectId)
                .name("example-ai-model-key")
                .cloud("ANY")
                .geography("ANY")
                .build());
    
            final var this = MongodbatlasFunctions.getAiModelApiKey(GetAiModelApiKeyArgs.builder()
                .projectId(projectId)
                .apiKeyId(thisAiModelApiKey.apiKeyId())
                .build());
    
            final var thisGetAiModelApiKeys = MongodbatlasFunctions.getAiModelApiKeys(GetAiModelApiKeysArgs.builder()
                .projectId(projectId)
                .build());
    
            ctx.export("aiModelApiKeyId", thisAiModelApiKey.apiKeyId());
            ctx.export("aiModelApiKeySecret", thisAiModelApiKey.secret());
            ctx.export("aiModelApiKeyName", this_.applyValue(_this_ -> _this_.name()));
            ctx.export("aiModelApiKeyEndpoint", this_.applyValue(_this_ -> _this_.endpoint()));
            ctx.export("aiModelApiKeysResults", thisGetAiModelApiKeys.results());
        }
    }
    
    resources:
      thisAiModelApiKey:
        type: mongodbatlas:AiModelApiKey
        name: this
        properties:
          projectId: ${projectId}
          name: example-ai-model-key
          cloud: ANY
          geography: ANY
    variables:
      this:
        fn::invoke:
          function: mongodbatlas:getAiModelApiKey
          arguments:
            projectId: ${projectId}
            apiKeyId: ${thisAiModelApiKey.apiKeyId}
      thisGetAiModelApiKeys:
        fn::invoke:
          function: mongodbatlas:getAiModelApiKeys
          arguments:
            projectId: ${projectId}
    outputs:
      aiModelApiKeyId: ${thisAiModelApiKey.apiKeyId}
      aiModelApiKeySecret: ${thisAiModelApiKey.secret}
      aiModelApiKeyName: ${this.name}
      aiModelApiKeyEndpoint: ${this.endpoint}
      aiModelApiKeysResults: ${thisGetAiModelApiKeys.results}
    
    pulumi {
      required_providers {
        mongodbatlas = {
          source = "pulumi/mongodbatlas"
        }
      }
    }
    
    data "mongodbatlas_getaimodelapikey" "this" {
      project_id = projectId
      api_key_id = mongodbatlas_aimodelapikey.this.api_key_id
    }
    data "mongodbatlas_getaimodelapikeys" "thisGetAiModelApiKeys" {
      project_id = projectId
    }
    
    resource "mongodbatlas_aimodelapikey" "this" {
      project_id = projectId
      name       = "example-ai-model-key"
      cloud      = "ANY"
      geography  = "ANY"
    }
    output "aiModelApiKeyId" {
      value = mongodbatlas_aimodelapikey.this.api_key_id
    }
    output "aiModelApiKeySecret" {
      value = mongodbatlas_aimodelapikey.this.secret
    }
    output "aiModelApiKeyName" {
      value = data.mongodbatlas_getaimodelapikey.this.name
    }
    output "aiModelApiKeyEndpoint" {
      value = data.mongodbatlas_getaimodelapikey.this.endpoint
    }
    output "aiModelApiKeysResults" {
      value = data.mongodbatlas_getaimodelapikeys.thisGetAiModelApiKeys.results
    }
    

    Using getAiModelApiKeys

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getAiModelApiKeys(args: GetAiModelApiKeysArgs, opts?: InvokeOptions): Promise<GetAiModelApiKeysResult>
    function getAiModelApiKeysOutput(args: GetAiModelApiKeysOutputArgs, opts?: InvokeOutputOptions): Output<GetAiModelApiKeysResult>
    def get_ai_model_api_keys(project_id: Optional[str] = None,
                              opts: Optional[InvokeOptions] = None) -> GetAiModelApiKeysResult
    def get_ai_model_api_keys_output(project_id: pulumi.Input[Optional[str]] = None,
                              opts: Optional[InvokeOutputOptions] = None) -> Output[GetAiModelApiKeysResult]
    func LookupAiModelApiKeys(ctx *Context, args *LookupAiModelApiKeysArgs, opts ...InvokeOption) (*LookupAiModelApiKeysResult, error)
    func LookupAiModelApiKeysOutput(ctx *Context, args *LookupAiModelApiKeysOutputArgs, opts ...InvokeOption) LookupAiModelApiKeysResultOutput

    > Note: This function is named LookupAiModelApiKeys in the Go SDK.

    public static class GetAiModelApiKeys 
    {
        public static Task<GetAiModelApiKeysResult> InvokeAsync(GetAiModelApiKeysArgs args, InvokeOptions? opts = null)
        public static Output<GetAiModelApiKeysResult> Invoke(GetAiModelApiKeysInvokeArgs args, InvokeOptions? opts = null)
        public static Output<GetAiModelApiKeysResult> Invoke(GetAiModelApiKeysInvokeArgs args, InvokeOutputOptions opts)
    }
    public static CompletableFuture<GetAiModelApiKeysResult> getAiModelApiKeys(GetAiModelApiKeysArgs args, InvokeOptions options)
    public static Output<GetAiModelApiKeysResult> getAiModelApiKeys(GetAiModelApiKeysArgs args, InvokeOptions options)
    public static Output<GetAiModelApiKeysResult> getAiModelApiKeys(GetAiModelApiKeysArgs args, InvokeOutputOptions options)
    
    fn::invoke:
      function: mongodbatlas:index/getAiModelApiKeys:getAiModelApiKeys
      arguments:
        # arguments dictionary
    data "mongodbatlas_get_ai_model_api_keys" "name" {
        # arguments
    }

    The following arguments are supported:

    ProjectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    ProjectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    project_id string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    projectId String
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    projectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    project_id str
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    projectId String
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.

    getAiModelApiKeys Result

    The following output properties are available:

    ProjectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    Results List<GetAiModelApiKeysResult>
    List of returned documents that MongoDB Cloud provides when completing this request.
    ProjectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    Results []GetAiModelApiKeysResult
    List of returned documents that MongoDB Cloud provides when completing this request.
    project_id string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    results list(object)
    List of returned documents that MongoDB Cloud provides when completing this request.
    projectId String
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    results List<GetAiModelApiKeysResult>
    List of returned documents that MongoDB Cloud provides when completing this request.
    projectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    results GetAiModelApiKeysResult[]
    List of returned documents that MongoDB Cloud provides when completing this request.
    project_id str
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    results Sequence[GetAiModelApiKeysResult]
    List of returned documents that MongoDB Cloud provides when completing this request.
    projectId String
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    results List<Property Map>
    List of returned documents that MongoDB Cloud provides when completing this request.

    Supporting Types

    GetAiModelApiKeysResult

    ApiKeyId string
    Identifier used to reference this API key in admin API calls.
    Cloud string
    Cloud provider scope for this API key. Use "ANY" for cloud-agnostic scope.
    CreatedAt string
    UTC date when the API key was created. This parameter is formatted as an ISO 8601 timestamp.
    CreatedBy string
    Name of the user that created this API key. If no user name is available, the user ID is returned.
    Endpoint string
    Server-computed endpoint hostname derived from cloud and geography. This field is read-only and must not be supplied in request bodies.
    Geography string
    Geography scope for this API key. Use "ANY" for geography-agnostic scope.
    LastUsedAt string
    UTC date when the API key was last used. This parameter is formatted as an ISO 8601 timestamp.
    MaskedSecret string
    A partially obfuscated version of the API key secret returned when the API key was created.
    Name string
    Arbitrary string identifier assigned to this API key for convenient identification.
    ProjectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    Status string
    A string describing the current status of the API key.
    ApiKeyId string
    Identifier used to reference this API key in admin API calls.
    Cloud string
    Cloud provider scope for this API key. Use "ANY" for cloud-agnostic scope.
    CreatedAt string
    UTC date when the API key was created. This parameter is formatted as an ISO 8601 timestamp.
    CreatedBy string
    Name of the user that created this API key. If no user name is available, the user ID is returned.
    Endpoint string
    Server-computed endpoint hostname derived from cloud and geography. This field is read-only and must not be supplied in request bodies.
    Geography string
    Geography scope for this API key. Use "ANY" for geography-agnostic scope.
    LastUsedAt string
    UTC date when the API key was last used. This parameter is formatted as an ISO 8601 timestamp.
    MaskedSecret string
    A partially obfuscated version of the API key secret returned when the API key was created.
    Name string
    Arbitrary string identifier assigned to this API key for convenient identification.
    ProjectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    Status string
    A string describing the current status of the API key.
    api_key_id string
    Identifier used to reference this API key in admin API calls.
    cloud string
    Cloud provider scope for this API key. Use "ANY" for cloud-agnostic scope.
    created_at string
    UTC date when the API key was created. This parameter is formatted as an ISO 8601 timestamp.
    created_by string
    Name of the user that created this API key. If no user name is available, the user ID is returned.
    endpoint string
    Server-computed endpoint hostname derived from cloud and geography. This field is read-only and must not be supplied in request bodies.
    geography string
    Geography scope for this API key. Use "ANY" for geography-agnostic scope.
    last_used_at string
    UTC date when the API key was last used. This parameter is formatted as an ISO 8601 timestamp.
    masked_secret string
    A partially obfuscated version of the API key secret returned when the API key was created.
    name string
    Arbitrary string identifier assigned to this API key for convenient identification.
    project_id string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    status string
    A string describing the current status of the API key.
    apiKeyId String
    Identifier used to reference this API key in admin API calls.
    cloud String
    Cloud provider scope for this API key. Use "ANY" for cloud-agnostic scope.
    createdAt String
    UTC date when the API key was created. This parameter is formatted as an ISO 8601 timestamp.
    createdBy String
    Name of the user that created this API key. If no user name is available, the user ID is returned.
    endpoint String
    Server-computed endpoint hostname derived from cloud and geography. This field is read-only and must not be supplied in request bodies.
    geography String
    Geography scope for this API key. Use "ANY" for geography-agnostic scope.
    lastUsedAt String
    UTC date when the API key was last used. This parameter is formatted as an ISO 8601 timestamp.
    maskedSecret String
    A partially obfuscated version of the API key secret returned when the API key was created.
    name String
    Arbitrary string identifier assigned to this API key for convenient identification.
    projectId String
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    status String
    A string describing the current status of the API key.
    apiKeyId string
    Identifier used to reference this API key in admin API calls.
    cloud string
    Cloud provider scope for this API key. Use "ANY" for cloud-agnostic scope.
    createdAt string
    UTC date when the API key was created. This parameter is formatted as an ISO 8601 timestamp.
    createdBy string
    Name of the user that created this API key. If no user name is available, the user ID is returned.
    endpoint string
    Server-computed endpoint hostname derived from cloud and geography. This field is read-only and must not be supplied in request bodies.
    geography string
    Geography scope for this API key. Use "ANY" for geography-agnostic scope.
    lastUsedAt string
    UTC date when the API key was last used. This parameter is formatted as an ISO 8601 timestamp.
    maskedSecret string
    A partially obfuscated version of the API key secret returned when the API key was created.
    name string
    Arbitrary string identifier assigned to this API key for convenient identification.
    projectId string
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    status string
    A string describing the current status of the API key.
    api_key_id str
    Identifier used to reference this API key in admin API calls.
    cloud str
    Cloud provider scope for this API key. Use "ANY" for cloud-agnostic scope.
    created_at str
    UTC date when the API key was created. This parameter is formatted as an ISO 8601 timestamp.
    created_by str
    Name of the user that created this API key. If no user name is available, the user ID is returned.
    endpoint str
    Server-computed endpoint hostname derived from cloud and geography. This field is read-only and must not be supplied in request bodies.
    geography str
    Geography scope for this API key. Use "ANY" for geography-agnostic scope.
    last_used_at str
    UTC date when the API key was last used. This parameter is formatted as an ISO 8601 timestamp.
    masked_secret str
    A partially obfuscated version of the API key secret returned when the API key was created.
    name str
    Arbitrary string identifier assigned to this API key for convenient identification.
    project_id str
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    status str
    A string describing the current status of the API key.
    apiKeyId String
    Identifier used to reference this API key in admin API calls.
    cloud String
    Cloud provider scope for this API key. Use "ANY" for cloud-agnostic scope.
    createdAt String
    UTC date when the API key was created. This parameter is formatted as an ISO 8601 timestamp.
    createdBy String
    Name of the user that created this API key. If no user name is available, the user ID is returned.
    endpoint String
    Server-computed endpoint hostname derived from cloud and geography. This field is read-only and must not be supplied in request bodies.
    geography String
    Geography scope for this API key. Use "ANY" for geography-agnostic scope.
    lastUsedAt String
    UTC date when the API key was last used. This parameter is formatted as an ISO 8601 timestamp.
    maskedSecret String
    A partially obfuscated version of the API key secret returned when the API key was created.
    name String
    Arbitrary string identifier assigned to this API key for convenient identification.
    projectId String
    Unique 24-hexadecimal digit string that identifies your project, also known as groupId in the official documentation.
    status String
    A string describing the current status of the API key.

    Package Details

    Repository
    MongoDB Atlas pulumi/pulumi-mongodbatlas
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the mongodbatlas Terraform Provider.
    mongodbatlas logo mongodbatlas logo
    Viewing docs for MongoDB Atlas v4.15.0
    published on Friday, Aug 28, 2026 by Pulumi

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial