Skip to main content

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.

Overview

Creates a new namespace for documents (text) or precomputed embeddings (vector). Returns the parsed API response as a dict.

Method

client.create_namespace(payload: dict) -> dict

API

POST /namespaces — see Create namespace

Payload

namespace_name
string
required
Unique name (alphanumeric, -, _). You may also send this field as name.
type
string
required
"text" for document storage or "vector" for precomputed embeddings.
vector_dimension
number
Required when type is "vector". Must be greater than 0. Must not be sent for text namespaces.

Example

from moorcheh import MoorchehApiClient, MoorchehApiError

client = MoorchehApiClient("http://localhost:8080")

# Text namespace
result = client.create_namespace({
    "namespace_name": "my-documents",
    "type": "text",
})

# Vector namespace
result = client.create_namespace({
    "namespace_name": "my-embeddings",
    "type": "vector",
    "vector_dimension": 768,
})

Returns

status
string
"success" when the namespace was created.
message
string
Human-readable result description.
namespace_name
string
Name of the namespace that was created.
type
string
"text" or "vector".
vector_dimension
number | null
Fixed vector length for vector namespaces; null for text namespaces.
Example return value (text)
{
  "status": "success",
  "message": "Namespace 'my-documents' created successfully.",
  "namespace_name": "my-documents",
  "type": "text",
  "vector_dimension": None,
}

Errors

Non-2xx responses raise MoorchehApiError. Use e.status_code and e.body for details.
from moorcheh import MoorchehApiError

try:
    client.create_namespace({"namespace_name": "my-documents", "type": "text"})
except MoorchehApiError as e:
    print(e.status_code, e.body)  # 409 if namespace already exists
StatusCause
400Invalid name or vector_dimension rules
409Namespace already exists