For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
CoreWeave Serverless Inference
Route agentgateway LLM traffic to open models and custom LoRA adapters served by CoreWeave Serverless Inference.
Configure CoreWeave Serverless Inference as an LLM provider in agentgateway. The coreweave provider sends Chat Completions requests to the CoreWeave Serverless Inference API at https://api.inference.wandb.ai/v1.
CoreWeave Serverless Inference serves the open models in the CoreWeave model list and the custom LoRA adapters that you upload to your CoreWeave team. Model names use the Hugging Face <vendor>/<model> format, such as meta-llama/Llama-3.1-8B-Instruct. LoRA adapters use a wandb-artifact:/// URI as the model name. For more information, see Serve a custom LoRA adapter.
Agentgateway converts Messages and Responses requests to Chat Completions before sending them to CoreWeave. For translated Responses requests, include the conversation history in input on each turn. Use /v1/chat/completions for image inputs because Responses conversion drops images.
Before you begin
- Install the
agentgatewaybinary. - Get an API key from your CoreWeave settings.
Configuration
You can add the model in the UI or in your configuration file.
To add the model in the UI, follow these steps.
Set your API key in the
COREWEAVE_API_KEYenvironment variable. The UI checks that the variable exists when you save the model.export COREWEAVE_API_KEY='<your-api-key>'Create a configuration file with an empty
llmsection, and start agentgateway in the same terminal. Without anllmsection, the UI does not show the LLM > Models page.cat > config.yaml <<'EOF' # yaml-language-server: $schema=https://agentgateway.dev/schema/config llm: models: [] EOF agentgateway -f config.yamlOpen LLM > Models, such as http://localhost:15000/ui/llm/models, and click Add model.
From the Provider dropdown, select CoreWeave Serverless Inference.
Keep the default
coreweave/*in the Incoming model match field.For the Provider API key, select Env var, and enter
COREWEAVE_API_KEY.For Outgoing model, keep Strip coreweave/. This option removes the
coreweave/prefix before the request is forwarded. To send every request to one model instead, select Explicit, and enter the model name. This option setsparams.model.Click Save model.
The form has no field for params.baseUrl. To override the base URL, click the Raw icon (<>) in the drawer header and add the field, or use the Config file tab.
Whether the UI can save depends on your storage mode. For more information, see Save changes from the UI.
Example request
After you run agentgateway with the configuration from the previous section, send an OpenAI-compatible request to the /v1/chat/completions endpoint.
curl -X POST http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "coreweave/meta-llama/Llama-3.1-8B-Instruct",
"messages": [{"role": "user", "content": "Hello from CoreWeave!"}]
}'Attribute usage to a Forge project
By default, CoreWeave attributes usage to the inference project in your default team. To attribute usage to a different project, add the following to the model entry and replace my-team/my-project with your Forge team and project.
requestHeaders:
set:
OpenAI-Project: my-team/my-projectServe a custom LoRA adapter
CoreWeave Serverless Inference can serve a LoRA adapter on top of a supported base model. You upload the adapter to your CoreWeave team as a lora artifact. Then, you send the artifact URI as the model name. Agentgateway forwards the URI to CoreWeave without changes, so you do not need a separate model entry for each adapter.
Train or export a LoRA adapter in PEFT format for a base model that supports LoRA. For the list of base models and the maximum LoRA rank for each, see Bring your own LoRA.
Upload the adapter as a
loraartifact. Setwandb.base_modelto the base model andstorage_regiontocoreweave-us. For a complete example, see the Create a LoRA tutorial.import wandb run = wandb.init(entity="my-team", project="my-project") artifact = wandb.Artifact( "my_lora", type="lora", metadata={"wandb.base_model": "meta-llama/Llama-3.1-8B-Instruct"}, storage_region="coreweave-us", ) artifact.add_dir("<path-to-lora-weights>") run.log_artifact(artifact)Send a request with the artifact URI as the model name. The URI has the format
wandb-artifact:///<team>/<project>/<artifact-name>:<alias-or-version>. Add thecoreweave/prefix so that the request matches thecoreweave/*model.curl -X POST http://localhost:4000/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "coreweave/wandb-artifact:///my-team/my-project/my_lora:latest", "messages": [{"role": "user", "content": "Say hello."}] }'
Roll out a new adapter version
Give each pinned artifact version a model name. This example serves version v4 as support-agent and lets clients try version v5 as support-agent-preview. Replace the artifact paths and versions with your own.
llm:
models:
- name: support-agent
provider: coreweave
params:
apiKey: "$COREWEAVE_API_KEY"
model: "wandb-artifact:///my-team/my-project/my_lora:v4"
- name: support-agent-preview
provider: coreweave
params:
apiKey: "$COREWEAVE_API_KEY"
model: "wandb-artifact:///my-team/my-project/my_lora:v5"List both names with GET /v1/models and send a Chat Completions request with "model": "support-agent-preview" to try v5. Promote it by updating support-agent to point to v5, or roll back by restoring v4. Clients keep using support-agent.
The built-in model catalog includes prices for the CoreWeave base models. The catalog does not include LoRA artifact URIs, so agentgateway does not compute a cost for LoRA requests unless you add the URIs to a custom model catalog.
Response settings and prefix caching
For Chat Completions requests, agentgateway forwards the CoreWeave response settings, including JSON mode and structured output (response_format), tool calling (tools and tool_choice), and streaming (stream). For streaming requests, agentgateway sets stream_options.include_usage so that it can record token usage.
CoreWeave caches prompt prefixes automatically on supported models. When a response reuses the cache, CoreWeave reports the cached tokens in usage.prompt_tokens_details.cached_tokens. Agentgateway records these tokens as cache reads and uses the cache read price from the model catalog to compute the cost.
CoreWeave can reuse a cached prefix for any request that has the same prefix and the same cache_salt value. All requests through agentgateway use the same CoreWeave API key. To keep the cache of one caller separate from the cache of other callers, set cache_salt for each caller. Use a final transformation, so that agentgateway sets cache_salt after it converts Messages and Responses requests to Chat Completions. A transformation that runs before the conversion does not keep cache_salt.
The following example sets cache_salt from the sub claim of the caller’s JWT. For the steps to configure JWT authentication, see JWT authentication. If you use virtual keys, you can use apiKey.user instead.
llm:
models:
- name: "coreweave/*"
provider: coreweave
params:
apiKey: "$COREWEAVE_API_KEY"
transformation:
model: llmRequest.model.stripPrefix("coreweave/")
finalTransformation:
cache_salt: '"tenant-" + jwt.sub'Use a custom provider in earlier versions
Versions of agentgateway before the coreweave provider was added can connect to CoreWeave Serverless Inference with a custom provider. Declare only the completions format, because CoreWeave serves only the Chat Completions API.
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
llm:
models:
- name: "coreweave/*"
provider:
custom:
formats:
- type: completions
params:
apiKey: "$COREWEAVE_API_KEY"
baseUrl: "https://api.inference.wandb.ai/v1"
transformation:
model: llmRequest.model.stripPrefix("coreweave/")