Skip to main content

Development with Generative AI

This page explains how to have generative AI and coding agents refer to the official AmiVoice API documentation to help with selecting an interface, investigating specifications, generating sample code, and more.

What is llms.txt​

llms.txt is an index file for generative AI that gathers links to the main specifications and documentation of AmiVoice API into one place. It is published at the following URL.

https://docs.amivoice.com/llms.txt

It is not a list of every page on the site. It selects and organizes the pages you should read first when choosing a method, implementing, and operating. The linked pages are the Markdown versions of the documentation, which are easy for generative AI to retrieve.

What You Can Do​

When you give llms.txt to a generative AI, you can use it for tasks such as the following.

  • Investigating the interface and parameters to use
  • Selecting a method that fits your requirements
  • Generating sample code
  • Support for development that uses new features
  • Code review

In every case, the goal is to have the official documentation referenced as the basis for the answer.

How to Use​

Add the URL of llms.txt to your instructions to the generative AI. When you tell it "Use this URL as the starting point and refer to the official documentation it links to," the generative AI opens the necessary pages and answers.

To get accurate answers, also add the following three points to your instructions.

  • Do not guess parameter names or specifications
  • If something is not written in the official documentation, state that it is not written
  • Include the URLs of the official documentation you referred to in the answer

The beginning of llms.txt also contains rules to follow when implementing. For example, there are rules such as "Do not determine success by the HTTP status alone" and "Do not output API keys to logs or configuration files." When generative AI is only given the URL, it may skip over these rules. When you have it write or review code, clearly tell it to "Follow the rules at the beginning."

Prompt Examples​

These are prompt examples you can copy and use as is. Rewrite the audio conditions or what you want to implement according to your purpose.

Selecting an Interface​

This is an example for handling a pre-recorded file.

Using https://docs.amivoice.com/llms.txt as the starting point,
please refer to the linked official AmiVoice API documentation.

When transcribing a pre-recorded audio file of about 30 minutes,
organize which interface, connection engine, and required request parameters to use.

Do not guess parameter names or specifications,
and include the URLs of the official documentation you referred to in your answer.

This is an example for sending audio in real time.

Using https://docs.amivoice.com/llms.txt as the starting point,
please refer to the linked official AmiVoice API documentation.

I want to send microphone audio from a browser in real time
and display interim recognition results on the screen.

Organize which to use among Synchronous HTTP, Asynchronous HTTP, and WebSocket,
along with the reasons, implementation steps, and documentation to refer to.

Generating Sample Code​

Using https://docs.amivoice.com/llms.txt as the starting point,
please refer to the linked official AmiVoice API documentation.

Write Python code that transcribes a 16 kHz, monaural, WAV-format audio file
using the Synchronous HTTP interface.

Get the API key from an environment variable, and do not include it in the URL query string.
Handle HTTP errors and the result code in the response body.
Follow the implementation rules at the beginning of llms.txt,
and do not guess endpoints or parameters that do not exist.

Also include the URLs of the official documentation you referred to in your answer.

Reviewing the Generated Code​

Do not use code written by generative AI as is; review it separately against the official documentation. If you do the review in a different conversation (session) from the one in which the code was written, you avoid carrying over the assumptions made when writing it. Review the entire code that calls the API, not only the changed parts.

Using https://docs.amivoice.com/llms.txt as the starting point,
please refer to the linked official AmiVoice API documentation.

Review the entire part of this code that calls AmiVoice API
against the official documentation.

First, go through the implementation rules at the beginning of llms.txt one by one,
and check for each rule whether the code follows it.
Next, check the endpoints, parameter names and formats, how the audio data is sent,
the handling of result codes, the logging settings, and the limit values against the reference.

Do not assume that processing not described in the official documentation is correct; state that it is not described.
For each issue you point out, show the relevant location in the code and the URL of the official documentation used as the basis.

Improving Recognition Accuracy​

Using https://docs.amivoice.com/llms.txt as the starting point,
please refer to the linked official AmiVoice API documentation.

I want to improve the recognition accuracy of audio that contains many technical terms.
Organize the available methods, such as the user dictionary and the choice of connection engine,
and show the setup steps for each and the documentation to refer to.

Do not guess specifications, and include the URLs of the official documentation you referred to in your answer.

Investigating Errors​

Using https://docs.amivoice.com/llms.txt as the starting point,
please refer to the linked official AmiVoice API documentation.

Organize the meaning of the result codes returned in the response of the Synchronous HTTP interface,
along with the likely causes and how to deal with them.

On the premise of checking not only the HTTP status but also the result code in the response body,
do not guess specifications, and show the URLs of the official documentation you referred to.

Common Mistakes Made by Generative AI​

When you use generative AI to write code for AmiVoice API, it seems prone to making mistakes such as the following. When checking code written by generative AI, pay particular attention to these points.

  • How to send the API key and where to keep it: It may put the API key in the URL query string. Because query strings remain in communication path logs, send the API key in the multipart HTTP body or in the Authorization header (Synchronous HTTP Interface). In applications that run in a browser, do not send the API key you own to the user's machine; use an API key with restrictions such as an expiration date or IP address restriction (Restrictions and Features That Can Be Applied to API Keys).
  • Determining success: With Synchronous HTTP, it treats a request as successful by looking only at the HTTP status. The Synchronous HTTP of AmiVoice API returns 200 OK even when recognition fails. The cause is set in code and message in the response body, and code is an empty string only on success (Response Codes and Messages). Do not treat a request as successful by looking only at the HTTP status.
  • Parameter format: When putting multiple parameters in d, it may write the connection engine name without grammarFileNames= and not URL encode the values. If a value contains a space, the parameters are not passed correctly. With Synchronous HTTP and Asynchronous HTTP, send the parameters as multipart and put the audio data in the last part (Synchronous HTTP Interface).
  • Choosing an interface: It sends a pre-recorded audio file with Synchronous HTTP without checking its size. There is an upper limit on the audio data that can be sent with Synchronous HTTP; use Asynchronous HTTP for long recordings and large files (Interface Type and Usage, Limitations).
  • Using the logging endpoint: It may not make it clear that it is using the logging endpoint. Sending audio to the logging endpoint means that you agree to the use of the audio data for service improvement and provide it (Logging). Make sure not to use the logging endpoint unintentionally.
  • Using the user dictionary: Although the user dictionary for a hybrid engine is split into one for 8k and one for 16k, it may create a bug in which only the one for 16k can be handled because adf is not specified (User Dictionary Registration API). Also, profileId must be set to use the user dictionary (How to Use User Dictionary).

These points are described in the rules of llms.txt and on the linked pages. Having the generative AI refer to llms.txt from the start and instructing it to follow the rules makes these mistakes easier to prevent.

How to Use It with AI That Cannot Refer to Web Pages​

To refer to llms.txt by URL, the generative AI needs the ability to read web pages. If it does not have that ability, paste the content directly into the prompt and use it that way.

https://docs.amivoice.com/llms.txt

However, llms.txt is a list of links. Just pasting it does not convey the detailed specifications of the linked pages. Use the following steps.

  1. Paste the content of llms.txt and have it identify the pages you need for your purpose.
  2. Then paste the Markdown version of the documentation for the identified pages as well.

You can retrieve the Markdown version by adding .md to the end of the page URL. For example, the Getting Started page is https://docs.amivoice.com/en/amivoice-api/manual/getting-started.md.

What You Cannot Do with llms.txt​

llms.txt is meant to make the official documentation easier to find and refer to. It cannot do the following.

  • Have the generative AI automatically connect to AmiVoice API
  • Have the generative AI run AmiVoice API directly as a tool
  • Guarantee the correctness of the generated code

Always check the generated code against the official reference before using it. Then, actually call the API to confirm how it behaves. Also checking the behavior when you make it fail on purpose, such as by using an incorrect API key, helps you find mistakes in error handling.

Notes on Usage​

Because this deals with a speech recognition API, pay particular attention to the following points.

Handling of API Keys and Voice Data
  • Before entering API keys, voice data, personal information, and the like into a generative AI, check the terms of service and the security rules of your organization. When entering code or error logs, always check that this information is not unintentionally included.
  • If you do not need to present the API key itself, replace it with a dummy value or an environment variable name.
  • Check the generated code against the official reference before using it.
  • Always check the pricing, limitations, terms of service, and SLA on the current official pages.