Skip to content

Switchyard lets LLM applications route traffic across models and providers while preserving native OpenAI and Anthropic API compatibility - enabling flexible model selection, benchmarking, and cost/performance optimization.

Rust
646 B
Raw Blame
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

//go:build cgo && switchyard_native

package switchyard

/*
#include "switchyard.h"
*/
import "C"

import "runtime/cgo"

// The handle stays registered until native free has joined every accepted callback.
//
//export syGoNext
func syGoNext(token C.uintptr_t, failure *C.char, output *C.char) {
	result := nativeNextResult{err: nativeError(failure)}
	if output != nil {
		result.data = []byte(C.GoString(output))
		C.sy_string_free(output)
	}
	cgo.Handle(token).Value().(chan nativeNextResult) <- result
}