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

# Create Namespace

> Create a new namespace using the Python SDK

## namespaces.create

Creates a new namespace for storing data.

### Parameters

<ParamField query="namespace_name" type="str" required>
  A unique name for the namespace.
</ParamField>

<ParamField query="type" type="str" required>
  The type of namespace: "text" or "vector".
</ParamField>

<ParamField query="vector_dimension" type="Optional[int]">
  The dimension of vectors. Required only if type is "vector".
</ParamField>

**Returns:** `Dict[str, Any]` - A dictionary confirming the creation details.

**Raises:** `ConflictError`, `InvalidInputError`.

### Examples

```python Create Text Namespace theme={null}
from moorcheh_sdk import MoorchehClient

with MoorchehClient() as client:
    # Create a text namespace for Moorcheh to handle embeddings
    result = client.namespaces.create(
        namespace_name="my-faq-documents",
        type="text"
    )
    print(f"Created namespace: {result}")
```

```python Create Vector Namespace theme={null}
from moorcheh_sdk import MoorchehClient

with MoorchehClient() as client:
    # Create a vector namespace for your own embeddings
    result = client.namespaces.create(
        namespace_name="my-image-embeddings",
        type="vector",
        vector_dimension=768
    )
    print(f"Created namespace: {result}")
```

### Error Handling

```python Error Handling Example theme={null}
from moorcheh_sdk import MoorchehClient, ConflictError, InvalidInputError

with MoorchehClient() as client:
    try:
        result = client.namespaces.create(
            namespace_name="my-documents",
            type="text"
        )
        print(f"Created namespace: {result}")
    except ConflictError:
        print("Namespace already exists")
    except InvalidInputError as e:
        print(f"Invalid input: {e}")
```

## Namespace Types

| Feature                 | Text Namespaces                      | Vector Namespaces                      |
| :---------------------- | :----------------------------------- | :------------------------------------- |
| **Primary Use**         | Storing and searching text documents | Storing pre-computed vector embeddings |
| **Embeddings**          | Automatically generated by Moorcheh  | Provided by you (custom embeddings)    |
| **Requirements**        | None                                 | Must specify vector dimension          |
| **Search Capabilities** | Full-text search                     | Vector similarity search               |
| **Ideal For**           | FAQs, documentation, articles        | Image embeddings, custom ML models     |

## Best Practices

* Use descriptive namespace names that indicate their purpose
* Separate different types of content into different namespaces
* Consider your data organization strategy before creating namespaces
* Text namespaces are easier to work with for most use cases
* Only use vector namespaces if you need to provide your own embeddings

## Related Operations

* [List Namespaces](/python-sdk/namespaces/list) - View all your namespaces
* [Delete Namespace](/python-sdk/namespaces/delete) - Remove a namespace
