Chunk and Perform Embedding
Upload a PDF to the Lowcademy Labs endpoint. It extracts the text, splits it into 800–1200-character semantic chunks, optionally calls Azure OpenAI Embeddings to generate a vector per chunk, and returns a payload you can POST directly to Azure AI Search without any modification. This is the first step in the RAG document ingestion pipeline.
| Property | Value |
|---|---|
| Method | POST |
| Content-Type | multipart/form-data |
| Parameters | All parameters passed as request headers — not query params or form fields |
| File Upload | PDF binary in the document multipart form field |
| Response | Azure AI Search Documents–Index API payload: { "value": [...] } |
performEmbedding: true. If you skip embedding, no Azure OpenAI variables are required.
https://my-resource.openai.azure.com/text-embedding-3-small
Lab API Key — For Training Use Only
api-keyankitg.in| Header | Type | Required | Description |
|---|---|---|---|
| api-key | String | Required | Fixed lab API key. Returns 401 if missing or incorrect. |
| Header | Type | Required | Description |
|---|---|---|---|
| sourceName | String | Required | Logical name for the document (e.g. AzureGuide). Written to every chunk's sourceName field. |
| tenant_id | Int64 | Required | Tenant identifier — must be numeric. Stored in every chunk. |
| document_id | Int64 | Required | Document identifier — must be numeric. Used to build the chunk id key. |
| performEmbedding | Boolean | Optional | Pass true to generate Azure OpenAI embeddings per chunk. Defaults to false; embedding array will be []. |
| embeddingEndpoint | String (URL) | Conditional | Your Azure OpenAI base URL. Required when performEmbedding: true. Maps to {{openAI_Endpoint}}. |
| embeddingKey | String | Conditional | Azure OpenAI API key. Required when performEmbedding: true. Maps to {{openAI_Key}}. |
| embeddingDeploymentName | String | Conditional | Embedding deployment name (e.g. text-embedding-3-small). Required when performEmbedding: true. Maps to {{openAI_EmbeddingModelName}}. |
| Field | Type | Required | Description |
|---|---|---|---|
| document | Binary (PDF) | Required | The PDF file. Must contain selectable text (not a scanned/image-only PDF). Send as multipart/form-data. |
cURL — with embedding (embedding array populated)
curl -X POST \ -H "api-key: ankitg.in" \ -H "sourceName: MyDocument" \ -H "tenant_id: 1" \ -H "document_id: 42" \ -H "performEmbedding: true" \ -H "embeddingEndpoint: https://my-resource.openai.azure.com" \ -H "embeddingKey: <your-azure-openai-key>" \ -H "embeddingDeploymentName: text-embedding-3-small" \ -F "document=@/path/to/document.pdf" \ https://labs.lowcademy.com/apis/chunk-and-perform-embedding.php
cURL — without embedding (embedding will be [])
curl -X POST \ -H "api-key: ankitg.in" \ -H "sourceName: MyDocument" \ -H "tenant_id: 1" \ -H "document_id: 42" \ -F "document=@/path/to/document.pdf" \ https://labs.lowcademy.com/apis/chunk-and-perform-embedding.php
/docs/index. No wrapping or transformation needed. Copy and send directly.
| Field | Type | Description |
|---|---|---|
| value | Array | Array of chunk objects ready for Azure AI Search indexing. |
| value[].@search.action | String | Always "upload". |
| value[].id | String | Unique key: {tenant_id}-{document_id}-{zero-padded-index}, e.g. 1-42-0001. |
| value[].tenant_id | Int64 | Echoed from the tenant_id header. |
| value[].document_id | Int64 | Echoed from the document_id header. |
| value[].sourceName | String | Echoed from the sourceName header. |
| value[].section | String | Detected heading for this chunk (max 90 chars). |
| value[].content | String | Chunk text, 800–1200 characters. |
| value[].embedding | Array<float> | 1536-dim float array when performEmbedding: true. Empty [] otherwise. |
Sample Response
{
"value": [
{
"@search.action" : "upload",
"id" : "1-42-0001",
"tenant_id" : 1,
"document_id" : 42,
"sourceName" : "MyDocument",
"section" : "Introduction",
"content" : "Azure AI Search is a fully managed cloud search service...",
"embedding" : [ 0.0023064255, -0.009327292, ... ] // 1536 floats
},
// more chunks...
]
}api-key header missing or wrong.tenant_id/document_id non-numeric, no file, or not a PDF. Also returned when performEmbedding: true but embedding headers are missing.POST https://<service>.search.windows.net/indexes/<index-name>/docs/index?api-version=2025-05-01-previewapi-key: <your-search-api-key> and Content-Type: application/json.