Skip to content

Cliente Ktor de NordRouter

kotlin
val client = HttpClient(CIO) {
    install(ContentNegotiation) { json() }
}

val response: JsonObject = client.post(
    "https://nordrouter.com/v1/chat/completions"
) {
    bearerAuth(System.getenv("NORDROUTER_API_KEY"))
    contentType(ContentType.Application.Json)
    setBody(buildJsonObject {
        put("model", "anthropic/claude-sonnet-4.6")
        putJsonArray("messages") {
            addJsonObject { put("role", "user"); put("content", "Привет!") }
        }
    })
}.body()

Para Android, armazene a chave do usuário em um armazenamento seguro. A chave compartilhada do app não pode ser incorporada com segurança em um APK.

Todos os programas