All URIs are relative to https://api.telnyx.com/v2
| Method | HTTP request | Description |
|---|---|---|
| chatPublicChatCompletionsPost | POST /ai/chat/completions | Create a chat completion |
| getModelsPublicModelsGet | GET /ai/models | Get available models |
| postSummary | POST /ai/summarize | Summarize file content |
Object chatPublicChatCompletionsPost(chatCompletionRequest)
Create a chat completion
Chat with a language model. This endpoint is consistent with the OpenAI Chat Completions API and may be used with the OpenAI JS or Python SDK.
// Import classes:
import com.telnyx.sdk.ApiClient;
import com.telnyx.sdk.ApiException;
import com.telnyx.sdk.Configuration;
import com.telnyx.sdk.auth.*;
import com.telnyx.sdk.model.*;
import com.telnyx.sdk.api.ChatApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.telnyx.com/v2");
// Configure HTTP bearer authorization: bearerAuth
HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth");
bearerAuth.setBearerToken("BEARER TOKEN");
ChatApi apiInstance = new ChatApi(defaultClient);
ChatCompletionRequest chatCompletionRequest = new ChatCompletionRequest(); // ChatCompletionRequest |
try {
Object result = apiInstance.chatPublicChatCompletionsPost(chatCompletionRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ChatApi#chatPublicChatCompletionsPost");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| chatCompletionRequest | ChatCompletionRequest |
Object
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Successful Response | - |
| 422 | Validation Error | - |
ModelsResponse getModelsPublicModelsGet()
Get available models
This endpoint returns a list of Open Source and OpenAI models that are available for use.
Note: Model id's will be in the form {source}/{model_name}. For example openai/gpt-4 or mistralai/Mistral-7B-Instruct-v0.1 consistent with HuggingFace naming conventions.
// Import classes:
import com.telnyx.sdk.ApiClient;
import com.telnyx.sdk.ApiException;
import com.telnyx.sdk.Configuration;
import com.telnyx.sdk.auth.*;
import com.telnyx.sdk.model.*;
import com.telnyx.sdk.api.ChatApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.telnyx.com/v2");
// Configure HTTP bearer authorization: bearerAuth
HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth");
bearerAuth.setBearerToken("BEARER TOKEN");
ChatApi apiInstance = new ChatApi(defaultClient);
try {
ModelsResponse result = apiInstance.getModelsPublicModelsGet();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ChatApi#getModelsPublicModelsGet");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}This endpoint does not need any parameter.
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Successful Response | - |
| 422 | Validation Error | - |
SummaryResponseData postSummary(summaryRequest)
Summarize file content
Generate a summary of a file's contents.
Supports the following text formats:
- PDF, HTML, txt, json, csv
Supports the following media formats (billed for both the transcription and summary):
- flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm
- Up to 100 MB
// Import classes:
import com.telnyx.sdk.ApiClient;
import com.telnyx.sdk.ApiException;
import com.telnyx.sdk.Configuration;
import com.telnyx.sdk.auth.*;
import com.telnyx.sdk.model.*;
import com.telnyx.sdk.api.ChatApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.telnyx.com/v2");
// Configure HTTP bearer authorization: bearerAuth
HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth");
bearerAuth.setBearerToken("BEARER TOKEN");
ChatApi apiInstance = new ChatApi(defaultClient);
SummaryRequest summaryRequest = new SummaryRequest(); // SummaryRequest |
try {
SummaryResponseData result = apiInstance.postSummary(summaryRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ChatApi#postSummary");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| summaryRequest | SummaryRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Successful Response | - |
| 422 | Validation Error | - |