Crestapps core openai

From CrestApps/CrestApps.AgentSkills · View interactive version

Crestapps core openai is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for using OpenAI and OpenAI-compatible endpoints in CrestApps.Core 2.0. Covers AddOpenAI and AddCoreAIOpenAI registration, connections under CrestApps AI Connections with ApiKey, Endpoint and the ChatApi setting (Auto, ChatCompletions, Responses) that sends reasoning requests with tools to the

How to use this skill

Skill file

CrestApps.Core OpenAI

The CrestApps.Core.AI.OpenAI package connects CrestApps.Core to api.openai.com and to any server that speaks the OpenAI API. The connection holds credentials and the endpoint; each deployment names a model and declares what that model can do.

Guidelines

Registration

using CrestApps.Core.AI.OpenAI;

builder.Services.AddCrestAppsCore(crestApps => crestApps
    .AddAISuite(ai => ai
        .AddOpenAI()
    )
);

AddAISuite(...) already calls AddCoreServices(), AddCoreAIServices() and AddCoreAIOrchestration(). Without the builder, register them yourself:

builder.Services
    .AddCoreAIServices()
    .AddCoreAIOrchestration()
    .AddCoreAIOpenAI();

AddCoreAIOpenAI() registers:

| Service | Implementation |

|---|---|

| IAIClientProvider | OpenAIClientProvider (chat, embeddings, images, speech-to-text, text-to-speech, realtime) |

| IAICompletionClient for "OpenAI" | ProviderAICompletionClient<OpenAIClientMarker> |

| IAIProviderConnectionHandler | OpenAIConnectionHandler (unprotects a stored OpenAIConnectionMetadata.ApiKey) |

| Connection source and deployment provider | Client name OpenAIConstants.ClientName ("OpenAI") |

Connection and Deployments

Connections are read from CrestApps:AI:Connections (or CrestApps:AI:Providers:OpenAI:Connections) and deployments from CrestApps:AI:Deployments. A configured deployment is read-only in the admin UI.

{
  "CrestApps": {
    "AI": {
      "Connections": [
        {
          "Name": "openai",
          "ClientName": "OpenAI",
          "ApiKey": "sk-..."
        }
      ],
      "Deployments": [
        {
          "ClientName": "OpenAI",
          "ConnectionName": "openai",
          "Name": "gpt-4.1",
          "ModelName": "gpt-4.1",
          "Features": [ "textGeneration", "toolCalling", "streaming", "imageInput" ]
        },
        {
          "ClientName": "OpenAI",
          "ConnectionName": "openai",
          "Name": "gpt-5-reasoning",
          "ModelName": "gpt-5",
          "Features": [ "textGeneration", "toolCalling", "streaming", "reasoning" ],
          "Parameters": {
            "reasoningEffort": {
              "AllowedValues": [ "None", "Low", "Medium", "High" ],
              "DefaultValue": "Low"
            }
          }
        },
        {
          "ClientName": "OpenAI",
          "ConnectionName": "openai",
          "Name": "text-embedding-3-small",
          "Features": [ "textEmbedding" ]
        },
        {
          "ClientName": "OpenAI",
          "ConnectionName": "openai",
          "Name": "gpt-4o-transcribe",
          "Features": [ "speechToText" ]
        },
        {
          "ClientName": "OpenAI",
          "ConnectionName": "openai",
          "Name": "gpt-4o-mini-tts",
          "Features": [ "textToSpeech" ]
        },
        {
          "ClientName": "OpenAI",
          "ConnectionName": "openai",
          "Name": "gpt-realtime",
          "Features": [ "realtime" ]
        }
      ]
    }
  }
}

Deployments declared on the connection

A connection can name its models directly instead. Each name becomes a read-only deployment with fixed capabilities:

| Connection key | Capabilities declared |

|---|---|

| ChatDeploymentName (or DeploymentName) | textGeneration, toolCalling, streaming |

| UtilityDeploymentName | textGeneration, streaming |

| EmbeddingDeploymentName | textEmbedding |

| ImagesDeploymentName | imageOutput |

| SpeechToTextDeploymentName | speechToText |

| TextToSpeechDeploymentName | textToSpeech |

Use the explicit Deployments list when a model needs reasoning, imageInput, realtime, or parameters.

Slots and Site Defaults

A slot is what the installation uses a deployment for. The built-in slots are chat, utility, embedding, image, vision, speechToText, textToSpeech and realtime. Fill a slot default through DefaultAIDeploymentSettings, then resolve it:

using CrestApps.Core.AI.Models;

builder.Services.Configure<DefaultAIDeploymentSettings>(settings =>
{
    settings.DefaultChatDeploymentName = "gpt-4.1";
    settings.DefaultUtilityDeploymentName = "gpt-4.1";
    settings.DefaultEmbeddingDeploymentName = "text-embedding-3-small";
    settings.DefaultSpeechToTextDeploymentName = "gpt-4o-transcribe";
    settings.DefaultTextToSpeechDeploymentName = "gpt-4o-mini-tts";
    settings.DefaultRealtimeDeploymentName = "gpt-realtime";
});
using CrestApps.Core.AI.Clients;
using CrestApps.Core.AI.Deployments;
using CrestApps.Core.AI.Models;
using Microsoft.Extensions.AI;

namespace MyApp.Services;

public sealed class EmbeddingService
{
    private readonly IAIDeploymentManager _deploymentManager;
    private readonly IAIClientFactory _clientFactory;

    public EmbeddingService(IAIDeploymentManager deploymentManager, IAIClientFactory clientFactory)
    {
        _deploymentManager = deploymentManager;
        _clientFactory = clientFactory;
    }

    public async Task<ReadOnlyMemory<float>> EmbedAsync(string text, CancellationToken cancellationToken = default)
    {
        var deployment = await _deploymentManager.ResolveSlotAsync(
            AIDeploymentSlotNames.Embedding,
            cancellationToken: cancellationToken)
            ?? throw new InvalidOperationException("No deployment declares the textEmbedding capability.");

        var generator = await _clientFactory.CreateEmbeddingGeneratorAsync(deployment);
        var embeddings = await generator.GenerateAsync([text], cancellationToken: cancellationToken);

        return embeddings[0].Vector;
    }
}

Resolution order is the explicit name, the slot's site default, the fallback slot (only utility falls back to chat), and finally the first deployment that declares the slot's capability. GetAllBySlotAsync(slotName) lists every candidate, which is what settings pickers use. ResolveSlotOrThrowAsync(...) throws instead of returning null.

Chat API and Reasoning Models

Reasoning models such as gpt-6-luna reject function tools combined with a reasoning effort on /v1/chat/completions. The connection's ChatApi setting (OpenAIChatApis) decides where such a request goes:

| ChatApi | Behavior |

|---|---|

| Auto (default) | On OpenAI's own endpoint (no Endpoint, api.openai.com, or a regional host such as eu.api.openai.com), a request with function tools and a reasoning effort other than None goes to the Responses API. Any other endpoint uses Chat Completions only. |

| ChatCompletions | Every request uses Chat Completions. |

| Responses | Tools plus reasoning go to /v1/responses on any endpoint. Use it for compatible servers such as OpenRouter or xAI. |

Values are case-insensitive; an unknown value logs a warning and acts as Auto. Responses requests are sent with store: false. A reasoning effort reaches the provider only when the deployment declares reasoning and the reasoningEffort parameter; without the parameter no effort is sent and Chat Completions rejects the tools. A host configured only from environment variables can set Parameters:reasoningEffort:DefaultValue=None for models that refuse tools unless the effort is none.

{
  "CrestApps": {
    "AI": {
      "Connections": [
        {
          "Name": "openrouter",
          "ClientName": "OpenAI",
          "Endpoint": "https://openrouter.ai/api/v1",
          "ApiKey": "...",
          "ChatApi": "Responses"
        }
      ]
    }
  }
}

Speech and Realtime

OpenAI-Compatible Servers

Set Endpoint to the server's base URL (for example Groq, Mistral, Together AI, Fireworks, DeepSeek, OpenRouter, vLLM, LocalAI). Declare only the features the hosted model really has; many servers lack tool calling, structured outputs, or /v1/responses. For Anthropic's native API prefer crestapps-core-claude-orchestrator.

Troubleshooting

Upgrading from 1.x

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.