OpenSearchMemory / Client / create_space

create_space

OpenSearchMemory.Client.create_space(**kwargs)

Creates a space. A space is an AWS resource that stores the events you send and the memories extracted from them, and defines the memory strategies that extract those memories.

The operation returns before provisioning finishes, with status CREATING. Call GetSpace until the status is ACTIVE, and then use the space. If provisioning fails, the status becomes FAILED and statusReason says why.

See also: AWS API Documentation

Request Syntax

response = client.create_space(
    name='string',
    memoryStrategies=[
        {
            'type': 'SEMANTIC'|'SUMMARY'|'CUSTOM',
            'name': 'string',
            'description': 'string',
            'configuration': {
                'extractionPrompt': 'string',
                'extractEveryNMessages': 123,
                'extractEveryNTokens': 123,
                'idleTimeoutSeconds': 123,
                'extractionSeedTopK': 123,
                'extractionSeedRecentN': 123,
                'consolidationEnabled': True|False
            }
        },
    ],
    eventExpiryDays=123,
    memoryExpiryDays=123,
    extractionModelId='string',
    encryptionConfiguration={
        'kmsKeyArn': 'string'
    },
    tags=[
        {
            'key': 'string',
            'value': 'string'
        },
    ],
    clientToken='string'
)
Parameters:
  • name (string) –

    [REQUIRED]

    A name for the space, unique within your account in the Region. If another space already has the name, the request fails with ConflictException.

  • memoryStrategies (list) –

    The memory strategies that extract memories from the space’s events: up to 10 strategies, each with a name that is unique within the space.

    Optional. Omit it, or send an empty list, to create a space with no memory strategies. Such a space stores the conversation events you send it and returns them through SearchEvents and ListEvents, but extracts no memories and has none to search. You can add strategies later with UpdateSpace.

    The serialized list can be at most 384 KiB.

    • (dict) –

      A memory strategy: how a space extracts one kind of memory from its events.

      • type (string) – [REQUIRED]

        The type of memory the strategy extracts.

      • name (string) –

        A name for the strategy, unique within the space. Omit it to have the service generate one from the type, for example semantic_1. The name must be 1 to 64 characters: letters, digits, periods, hyphens, and underscores, starting with a letter or digit. A strategy’s name can’t be changed, and the strategy’s memories are stored under it: a strategy added under a new name starts with no memories.

      • description (string) –

        A description of the strategy.

      • configuration (dict) –

        Settings for the strategy. When you create a strategy, omit it to use the defaults for the strategy’s type.

        A CUSTOM strategy must set extractionPrompt.

        • extractionPrompt (string) –

          Instructions that define what a CUSTOM strategy extracts, up to 30,720 characters. Required for a CUSTOM strategy: CreateSpace and UpdateSpace fail with ValidationException if a CUSTOM strategy has none.

          Only CUSTOM strategies use it. SEMANTIC and SUMMARY strategies always extract with the service’s built-in instructions: the service accepts and stores a prompt on them, and GetSpace returns it, but extraction doesn’t use it.

        • extractEveryNMessages (integer) –

          Extract once this many messages have accumulated, from 1 to 1000. Lower values extract more often, in smaller batches. The default is 12.

          Messages accumulate until the first of extractEveryNMessages, extractEveryNTokens, and idleTimeoutSeconds is reached. The service then extracts them together in one pass.

        • extractEveryNTokens (integer) –

          Extract once this many tokens of conversation have accumulated, from 1 to 80,000, however few messages that takes. Use it to bound how much text one extraction call carries when message sizes vary widely. Omit it to bound a batch only by extractEveryNMessages, idleTimeoutSeconds, and the service’s maximum batch size.

        • idleTimeoutSeconds (integer) –

          Extract what has accumulated once the conversation has been idle for this many seconds, from 1 to 86,400. The default is 60. This is what extracts the end of a conversation that stops. Raise it when the pauses in your conversations are longer than that, so that one exchange isn’t split across several extraction passes.

        • extractionSeedTopK (integer) –

          How many of the strategy’s stored memories that are most relevant to the conversation to include in the extraction prompt, from 0 to 20, to improve extraction and reduce duplicates. If you omit this or set it to 0, the service uses its default (see extractionSeedRecentN). When this and extractionSeedRecentN are both set, the two sets of memories are combined without duplicates.

        • extractionSeedRecentN (integer) –

          How many of the strategy’s most recent stored memories to include in the extraction prompt, from 0 to 20. If you omit this or set it to 0, the service uses its default: no seeding for most strategy types, and the 10 most recent memories for a SUMMARY strategy when neither seed setting is given. When this and extractionSeedTopK are both set, the two sets of memories are combined without duplicates.

        • consolidationEnabled (boolean) –

          Specifies whether the strategy consolidates memories. With consolidation, each new memory is compared with similar stored memories, and the service adds it, updates a stored memory, or skips it, so duplicate or contradicting facts don’t accumulate. Without it, every extracted memory is stored as a new memory, which costs less and keeps a full history.

          When omitted, the default depends on the strategy’s type: on for SEMANTIC and SUMMARY, off for CUSTOM.

  • eventExpiryDays (integer) – How many days the space keeps each event, from 1 to 365. The default is 90.

  • memoryExpiryDays (integer) –

    How many days the space keeps each memory, from 0 to 3650, counted from when the service writes the memory. Updating a memory with UpdateMemory doesn’t restart the count. 0 means memories never expire. If you omit it, memories never expire.

    Searches and lists leave out a memory past its expiry, and reading, updating, or deleting it returns ResourceNotFoundException.

  • extractionModelId (string) – The model that extracts and consolidates memories for every strategy in the space, as an Amazon Bedrock model ID without an inference-profile prefix: anthropic.claude-opus-5-5 or anthropic.claude-haiku-5-5. Another value fails with ValidationException, and the message lists the supported IDs. Omit it to use the service default, which can change over time and isn’t returned by GetSpace. Setting a value pins the model.

  • encryptionConfiguration (dict) –

    The AWS KMS key that encrypts the space’s data. Omit it, or omit its kmsKeyArn, to use an AWS owned key. You can’t change the key after you create the space.

    • kmsKeyArn (string) –

      The ARN of a customer managed AWS KMS key that encrypts the space’s data. The key must be an enabled symmetric encryption key in the space’s Region, and you need permission to create grants on it ( kms:CreateGrant). Otherwise, the request fails with ValidationException or AccessDeniedException.

  • tags (list) –

    The tags to add to the space.

    • (dict) –

      A tag: a key-value pair that you attach to a space.

      • key (string) – [REQUIRED]

        The key of the tag.

      • value (string) – [REQUIRED]

        The value of the tag.

  • clientToken (string) –

    A unique, case-sensitive identifier that makes the request idempotent. A retry with the same token and the same parameters within 2 hours returns the space that the first request created, instead of creating another. Reusing the token with different parameters, or while the first request is still in progress, fails with ConflictException.

    This field is autopopulated if not provided.

Return type:

dict

Returns:

Response Syntax

{
    'spaceId': 'string',
    'arn': 'string',
    'name': 'string',
    'status': 'CREATING'|'ACTIVE'|'UPDATING'|'DELETING'|'DELETED'|'FAILED',
    'createdAt': datetime(2015, 1, 1)
}

Response Structure

  • (dict) –

    • spaceId (string) –

      The ID of the space.

    • arn (string) –

      The Amazon Resource Name (ARN) of the space.

    • name (string) –

      The name of the space.

    • status (string) –

      The status of the space: CREATING.

    • createdAt (datetime) –

      When the space was created.

Exceptions