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

# Feature Extraction

> Examples of feature extraction inference with SynapsAI Cloud

Our feature extraction endpoint generates embeddings or feature vectors from text inputs, useful for semantic search, clustering, and downstream ML tasks.

Here is an example of feature extraction:

**Parameters:**

* `model`: The model ID of the model you want to use
* `inputs`: The text input(s) to extract features from (string or list of strings)

<CodeGroup>
  ```python title="Python" theme={null}
  from synapsai import SynapsAI

  model = SynapsAI("your-api-key")

  response = model.feature_extraction.create(
      model="model-id",
      inputs="This is a sample sentence for feature extraction."
  )

  for features in response.data:
      print("Features:", features)
  ```

  ```curl title="cURL" theme={null}
  curl -X POST https://api.synapsai.cloud/v1/feature-extraction \
    -H "Authorization: Bearer $SYNAPSAI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
          "model": "model-id",
          "inputs": "This is a sample sentence for feature extraction."
      }'
  ```
</CodeGroup>

Here is an example with multiple inputs:

<CodeGroup>
  ```python title="Python" theme={null}
  from synapsai import SynapsAI

  model = SynapsAI("your-api-key")

  response = model.feature_extraction.create(
      model="model-id",
      inputs=[
          "Machine learning is a fascinating field.",
          "Deep learning models can process large amounts of data.",
          "Natural language processing helps computers understand text."
      ]
  )

  for i, features in enumerate(response.data):
      print(f"Text {i+1} features:", features)
      print(f"Feature count: {len(features) if isinstance(features, list) else 'N/A'}")
      print("---")
  ```

  ```curl title="cURL" theme={null}
  curl -X POST https://api.synapsai.cloud/v1/feature-extraction \
    -H "Authorization: Bearer $SYNAPSAI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
          "model": "model-id",
          "inputs": [
            "Machine learning is a fascinating field.",
            "Deep learning models can process large amounts of data.",
            "Natural language processing helps computers understand text."
          ]
      }'
  ```
</CodeGroup>

Here is an example for semantic search preparation:

<CodeGroup>
  ```python title="Python" theme={null}
  from synapsai import SynapsAI
  import numpy as np

  model = SynapsAI("your-api-key")

  documents = [
      "The weather is sunny and warm today.",
      "I enjoy reading books about artificial intelligence.",
      "Cooking is one of my favorite hobbies.",
      "Python is a popular programming language for data science."
  ]

  response = model.feature_extraction.create(
      model="model-id",
      inputs=documents
  )

  # Store features for semantic search
  document_features = []
  for i, features in enumerate(response.data):
      document_features.append({
          "text": documents[i],
          "features": features
      })
      print(f"Indexed document {i+1}: {documents[i][:50]}...")

  print(f"\nTotal documents indexed: {len(document_features)}")
  ```

  ```curl title="cURL" theme={null}
  curl -X POST https://api.synapsai.cloud/v1/feature-extraction \
    -H "Authorization: Bearer $SYNAPSAI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
          "model": "model-id",
          "inputs": [
            "The weather is sunny and warm today.",
            "I enjoy reading books about artificial intelligence.",
            "Cooking is one of my favorite hobbies.",
            "Python is a popular programming language for data science."
          ]
      }'
  ```
</CodeGroup>

For deeper insights into the feature extraction endpoint, see our [API reference](https://docs.synapsai.cloud/api-reference/generic-feature-extraction).
