Julia tone checker quickstart
Send text to the tone endpoint. The response ranks overall tones and returns a separate probability breakdown for every sentence.
No language-specific SDK is required. The example uses a standard or commonly used HTTP client to call Sapling's JSON API.
Julia
/api/v1/tone
This example uses the HTTP.jl and JSON.jl packages.
using HTTP
using JSON
api_key = get(ENV, "SAPLING_API_KEY", "")
if isempty(api_key)
error("Set SAPLING_API_KEY first.")
end
url = "https://api.sapling.ai/api/v1/tone"
headers = [
"Authorization" => "Bearer $api_key",
"Content-Type" => "application/json",
]
payload = Dict(
"text" => "Really stoked about this! Will it be ready by next week?",
)
response = HTTP.post(url, headers, JSON.json(payload); status_exception=true)
println(String(response.body))
Example response
application/json
{
"overall": [
[0.9247, "curious", "🤓"],
[0.0455, "excited", "😀"],
[0.0057, "confused", "😕"]
],
"results": [
[[0.9937, "excited", "😀"]],
[[0.5469, "confused", "😕"], [0.3993, "curious", "🤓"]]
],
"sents": [
"Really stoked about this!",
"Will it be ready by next week?"
]
}
Probabilities are returned in descending order as probability, tone, and emoji tuples. Use sentence results when a message contains mixed tones.
About Julia
Julia is a popular programming language for data science applications in industry and academia like numerical analysis and computational science. It is designed to be dynamic, concurrent/parallel and includes efficient libraries for linear algebra and floating-point calculations.