Quick Start
Basic Usage Example
Full Documentation
- Each request might take longer periods of time to be completed, statement especially valid for the image creation API. Remember to set your request timeout to 120 seconds or greater to ensure that you receive the content of all AI generated content we send.
- If you exceed your monthly API credit count, the API will respond with an error, prompting you that you are rate limited.
- The server is set to the UTC timezone, call counts will be reset monthly based on this time zone.
- Each request will return a JSON string containing the AI generated content, in the ‘result’ field. Also, the responses will contain the remaining API credit count, in the ‘remainingtokens’ field.
Generating AI Text and Images
1. Generating text using the AI writer
API Endpoint:
https://aiomaticapi.com/apis/ai/v1/text
Sample Call:
Result:
API parameters:
- apikey – *required – add your API key for the call – be sure to have a valid subscription for the call to work
- prompt – *required – add the prompt based on which the AI should generate text – for best results, be sure to urlencode the prompt so it is received correctly by the API.
- model – Select the model you wish to use when creating textual content. Available models are: text-davinci-003, text-davinci-002, text-curie-001, text-babbage-001, text-ada-001.
- temperature – Advanced parameter (optional). What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend altering this or top_p but not both.
- top_p – Advanced parameter (optional). An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.
- presence_penalty – Advanced parameter (optional). Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model’s likelihood to talk about new topics.
- frequency_penalty – Advanced parameter (optional). Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model’s likelihood to repeat the same line verbatim.
API result:
- remainingtokens – The number of API tokens remaining for your API key.
- result – The AI generated text.
– In case of error: a JSON with the following content:
- remainingtokens – The number of API calls remaining for your API key. In case of error, this might display 0. In case of errors, the used token count will not be increased.
- error – The error message containing the reason of the failure.
2. ChatGPT models usage
API Endpoint:
https://aiomaticapi.com/apis/ai/v1/chat
Sample Call:
Result:
API parameters:
- apikey – *required – add your API key for the call – be sure to have a valid subscription for the call to work
- messages – *required – if you make a GET request, simply add the prompt based on which the AI should generate text. If you make a POST request, be sure to add the following array in the POST request, in the “message” parameter: array(“role” => “user”, “content” => “YOUR_INPUT”). You can add an array of multiple messages, the possible roles are: “user”, “assistant” or “system”. You should add pretraining prompts in the first message, with the role “system”, afterwards add multiple “user” and “assistant” messages in the sent array.
- model – Select the model you wish to use when creating textual content. Available models are: gpt-3.5-turbo, gpt-3.5-turbo-0301, gpt-4, gpt-4-0314, gpt-4-32k, gpt-4-32k-0314.
- temperature – Advanced parameter (optional). What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend altering this or top_p but not both.
- top_p – Advanced parameter (optional). An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.
- presence_penalty – Advanced parameter (optional). Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model’s likelihood to talk about new topics.
- frequency_penalty – Advanced parameter (optional). Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model’s likelihood to repeat the same line verbatim.
API result:
- remainingtokens – The number of API tokens remaining for your API key.
- result – The AI generated text, in the following JSON encoded format: {“role”:”assistant”,”content”:”THE_AI_RESPONSE”}.
– In case of error: a JSON with the following content:
- remainingtokens – The number of API calls remaining for your API key. In case of error, this might display 0. In case of errors, the used token count will not be increased.
- error – The error message containing the reason of the failure.
3. Editing text using the AI editor
API Endpoint:
https://aiomaticapi.com/apis/ai/v1/edit
Sample Call:
Result:
API parameters:
- apikey – *required – add your API key for the call – be sure to have a valid subscription for the call to work
- instruction – *required – add the instruction based on which the AI should edit the text you send for processing – for best results, be sure to urlencode the instruction so it is received correctly by the API. Be sure to be as precise as possible when writing your instruction
- input – Send the text which you need to be processed by the AI editor. If no input is provided, the API will write its own content based on the instruction you send to it.
- model – Select the model you wish to use when editing textual content. Available models are: text-davinci-edit-001.
- temperature – Advanced parameter (optional). What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. For paraphrasing/translating or other similar tasks, we recommend setting temperature to 0. We generally recommend altering this or top_p but not both.
- top_p – Advanced parameter (optional). An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.
API result:
- remainingtokens – The number of API tokens remaining for your API key.
- result – The AI edited text.
– In case of error: a JSON with the following content:
- remainingtokens – The number of API calls remaining for your API key. In case of error, this might display 0. In case of errors, the used token count will not be increased.
- error – The error message containing the reason of the failure.
4. Generating images using the AI
API Endpoint:
https://aiomaticapi.com/apis/ai/v1/image
Sample Call:
Result:
API parameters:
- apikey – *required – add your API key for the call – be sure to have a valid subscription for the call to work
- prompt – *required – add the prompt based on which the AI should generate an image – for best results, be sure to urlencode the prompt so it is received correctly by the API.
- image_size – Select the image size which should be generated. Supported values are: 256×256, 512×512, 1024×1024.
API result:
- remainingtokens – The number of API tokens remaining for your API key.
- result – The URL of the AI generated image.
– In case of error: a JSON with the following content:
- remainingtokens – The number of API calls remaining for your API key. In case of error, this might display 0. In case of errors, the used token count will not be increased.
- error – The error message containing the reason of the failure.
What’s next?
There’s a lot more that you can configure and tune in AiomaticAPI to handle the needs of your application. Be sure to read about all the options it exposes and how to get the most out of this API.