Quick-start
Jump-start your journey with Embaas API services.
Welcome to the quick-start guide for Embaas. We'll walk you through the basic steps of making requests to our Document Extraction and Embeddings APIs.
Pre-requisites
To make a request to our APIs, you will need an API key for authentication. You can create this on your dashboard.
For the request body type, use multipart/form-data
for Document Extraction API and application/json
for Embeddings API.
Remember to replace {EMBAAS_API_KEY}
, {FILE_NAME}
and {FILE_PATH}
with your actual API key, file name, and file path respectively in the following examples.
Embeddings API
The following example demonstrates how to generate embeddings for a list of input texts using our Embeddings API.
1 2 3 4 5 6 7 8
from embaas import EmbaasClient client = EmbaasClient(api_key=EMBAAS_API_KEY) res = client.get_embeddings( model='all-MiniLM-L6-v2', texts=['This is an example sentence.', 'Here is another sentence.'] ) embeddings = res.data
Document Extraction API (Document to Embeddings)
Here is a basic example of how to extract text from a document and generate embeddings using our Document Extraction API.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
import requests url = "https://api.embaas.io/v1/document/extract-text/" headers = { 'Authorization': 'Bearer {EMBAAS_API_KEY}' } data = { 'chunk_size': '256', 'chunk_splitter': 'CharacterTextSplitter', 'should_embed': 'true', 'model': 'instructor-large', 'separators': '\n', 'chunk_overlap': '20', 'should_chunk': 'true', 'instruction': 'Represent the document statement' } files=[ ('file' ,('{FILE_NAME}', open('{FILE_PATH}', 'rb'), 'application/pdf')) ] response = requests.post(url, headers=headers, data=data, files=files) print(response.json())
Document Extraction API Reference
Congratulations, you've made your first successful requests to the Embaas APIs! If you run into any issues, please refer to our full API documentation or contact us.