Semantic Kernel (gateway)
Route Semantic Kernel chat completions through the Respan gateway to use models and provider credentials configured in Respan. Only your RESPAN_API_KEY is needed in the application.
Paste this into your coding agent:
Help me set up the Respan gateway with the Semantic Kernel integration.
Follow https://www.respan.ai/docs/integrations/gateway/semantic-kernel.mdSetup
Install packages
pip install semantic-kernel openaiSet environment variables
export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
export RESPAN_BASE_URL="https://gateway.respan.ai"
export RESPAN_MODEL="gpt-5-mini"No OPENAI_API_KEY is needed when the request is routed through the Respan gateway.
Point Semantic Kernel to the Respan gateway
import asyncio
import os
from openai import AsyncOpenAI
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
from semantic_kernel.connectors.ai.open_ai import OpenAIChatPromptExecutionSettings
from semantic_kernel.functions import KernelArguments
kernel = Kernel()
client = AsyncOpenAI(
api_key=os.environ["RESPAN_API_KEY"],
base_url=os.getenv("RESPAN_BASE_URL", "https://gateway.respan.ai"),
)
kernel.add_service(
OpenAIChatCompletion(
service_id="chat",
ai_model_id=os.getenv("RESPAN_MODEL", "gpt-5-mini"),
async_client=client,
)
)
async def main() -> None:
result = await kernel.invoke_prompt(
"Say hello through the Respan gateway.",
arguments=KernelArguments(
settings=OpenAIChatPromptExecutionSettings(
service_id="chat",
max_tokens=80,
)
),
)
print(result)
asyncio.run(main())Switch models
Change RESPAN_MODEL to another model available in your Respan account.
export RESPAN_MODEL="gpt-5.5"
export RESPAN_MODEL="gpt-5-mini"See the full model list .