# askai: Ask AI

> askai (Ask AI) is a 1001fx API function in the group AI: POST https://api.1001fx.com/ai/askai, 4 credits per 1,000 tokens (minimum 4). It works as a ready-made module in Make and n8n or as a plain HTTP call.

Gets an answer from an AI, based on predefined templates or a custom prompt. Charged per used tokens.

- This service is provided by an external service provider: Microsoft Azure OpenAI. The data of the call is sent to the provider. [More about service providers](https://1001fx.com/functions#serviceproviders)

- Group: AI
- Endpoint: `POST https://api.1001fx.com/ai/askai`
- Authentication: header `X-API-KEY: YOURSECRETAPIKEY`
- Content type: application/json
- Credits: 4 credits per 1,000 tokens (minimum 4)
- Ready-made in: Make and n8n
- Service provider: OpenAI
- Docs: https://1001fx.com/functions/askai

## Parameters

- `text` (string, required) – Text: Text that will be send to the AI
- `temperature` (number, optional, default `1`, min 0, max 2) – Temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
- `maxTokens` (number, optional, default `256`) – Max Tokens: The maximum number of tokens to generate in the completion. The token count of your prompt plus max_tokens cannot exceed the model's context length. Most models have a context length of 2048 tokens(except for the newest models, which support 4096). 1 token ~= 4 chararcters in english, 1 token ~= 3/4 words
- `model` (enum, optional, one of `gpt-3.5-turbo`, `gpt-4`, `gpt-6.1-terra`, `gpt-6-luna`, default `gpt-6.1-terra`) – Model: AI model to be used. Defaults to gpt-6.1-terra
- `systemMessage` (string, optional, default `You are a helpful assistant.`) – System Message: Provide an optional system message to use.
- `promptTemplate` (enum, required, one of `Summarize`, `Make Longer`, `Make Shorter`, `Check Spelling and Grammar`, `Change Tone`, `Simplify`, `Translate`, `Explain This`, `Find Action Items`, `Continue Writing`, `Anonymize Text`, `Add Details`, `Improve Writing`, `Custom`) – Prompt Template: AI model to be used.
- `params` (object, optional) – Additional parameters
  - `customPrompt` (string, optional) – Custom Prompt: Custom prompt to use. This field is only used if prompt is custom. Inlcude %TEXT% as a placeholder in your custom prompt to access the value provided in text.
  - `translationLanguage` (string, optional) – Translation Language: Language to translate your text to. This field is only used if prompt is Translate.
  - `tone` (string, optional) – Translation Language: Language to translate your text to. This field is only used if prompt is Translate.

## Use cases

- Summarize incoming support emails before they go into your helpdesk
- Translate product descriptions from a Google Sheet into another language
- Anonymize customer texts before you store or share them
- Pull action items out of meeting notes and post them to a task list

## Example: Summarize a text

```bash
curl -X POST 'https://api.1001fx.com/ai/askai' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"text":"Low-code platforms let teams build workflows by connecting ready-made blocks instead of writing code. They speed up delivery, but complex logic still needs developers.","promptTemplate":"Summarize","model":"gpt-6.1-terra","temperature":0,"maxTokens":256}'
```

## FAQ

**Which prompt templates are available?**

Summarize, Make Longer, Make Shorter, Check Spelling and Grammar, Change Tone, Simplify, Translate, Explain This, Find Action Items, Continue Writing, Anonymize Text, Add Details, Improve Writing and Custom.

**How do I use my own prompt?**

Choose the template Custom and write your prompt in params.customPrompt. The placeholder %TEXT% is replaced with the value of text.

**Why is the answer cut off?**

maxTokens limits the length of the answer and defaults to 256 tokens. Raise it for longer answers. The call is charged per used token.
