# TextVectorAPI

***

### **TextVectorAPI Reference**

**TextVectorAPI** は、入力されたテキストをベクトル形式に変換するための API です。この API を利用することで、テキストデータを機械学習モデルやデータ分析ツールで扱いやすい形式に変換できます。

***

#### **導入用途**

1. **自然言語処理（NLP）**\
   テキストデータのベクトル化により、クラスタリングや類似性分析を実現します。
2. **検索エンジンの強化**\
   ベクトル検索を用いて、意味的に関連性のあるドキュメントや回答を検索できます。
3. **推薦システムの構築**\
   テキストコンテンツ間の類似性を分析して、コンテンツの推薦機能を実装します。
4. **AIモデルの前処理**\
   テキストデータをエンコードして、ディープラーニングモデルの入力として使用します。

***

#### **Base URL**

```
https://textvectorapi-mixederapi.mixeder.com/
```

***

#### **Endpoints**

**GET /**

指定されたテキストをベクトル形式に変換します。

**Headers**

| ヘッダー名          | 必須 | 説明                 |
| -------------- | -- | ------------------ |
| `Content-Type` | はい | `application/json` |

**Query Parameters**

| パラメーター名 | 必須 | 説明          |
| ------- | -- | ----------- |
| `key`   | はい | 使用する API キー |
| `text`  | はい | ベクトル化するテキスト |

**Response**

* 成功時:\
  **HTTP Status**: 200\
  **Body**:

  ```json
  {
    "message": "API authentication, vectorization, and billing completed successfully",
    "username": "user",
    "vectorization": {
      "shape": [
        1,
        768
      ],
      "data": [
        [
          -0.0062803165055811405,
          0.02522544004023075,
          0.02596879191696644,
          0.0022791167721152306,
          0.014218125492334366,
          0.019512472674250603,
          0.006175754591822624,
          0.0308975987136364,
          -0.04236556962132454
        ]
      ]
    },
    "billingResponse": "{\"status\":\"success\"}"
  }
  ```
* エラー時:\
  **HTTP Status**: 400 または 500\
  **Body**:

  ```json
  {
    "error": "Error message"
  }
  ```

***

#### **サンプルコード**

**JavaScript Fetch Example**

```javascript
async function vectorizeText(apiKey, text) {
  const apiUrl = 'https://textvectorapi-mixederapi.mixeder.com/';
  
  const queryParams = new URLSearchParams({ key: apiKey, text });

  try {
    const response = await fetch(`${apiUrl}?${queryParams.toString()}`, {
      method: 'GET',
      headers: { 'Content-Type': 'application/json' },
    });

    if (!response.ok) {
      throw new Error(`API error: ${response.statusText}`);
    }

    const data = await response.json();
    console.log('Text vectorization result:', data.vectorization);
    return data.vectorization;
  } catch (error) {
    console.error('Error during text vectorization:', error.message);
    throw error;
  }
}

// 使用例
vectorizeText('your-api-key', 'example text')
  .then((result) => console.log('Vectorization Result:', result))
  .catch((err) => console.error('Vectorization failed:', err));
```

***

**Python Requests Example**

```python
import requests

def vectorize_text(api_key, text):
    api_url = 'https://textvectorapi-mixederapi.mixeder.com/'
    params = {
        "key": api_key,
        "text": text,
    }
    try:
        response = requests.get(api_url, params=params)
        response.raise_for_status()
        data = response.json()
        print("Text vectorization result:", data["vectorization"])
        return data["vectorization"]
    except requests.exceptions.RequestException as e:
        print("Error during text vectorization:", e)
        raise

# 使用例
vectorize_text("your-api-key", "example text")
```

***

**cURL Example**

```bash
curl -X GET 'https://textvectorapi-mixederapi.mixeder.com/?key=your-api-key&text=example%20text' \
  -H "Content-Type: application/json"
```

***

#### **料金計算**

1. **サービス名**: `TextVectorAPI`
2. **単位あたり料金**: 0.05


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.mixeder.net/biz-ai/textvectorapi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
